Skip to content

[abseil_cpp] Changed to build v20230125.0 #10560

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Feb 27, 2025

Conversation

stemann
Copy link
Contributor

@stemann stemann commented Feb 19, 2025

Added missing libabsl_flags product.

Also, added handling of microarch differences wrt. hardware AES flags by expanding architectures for aarch64, x86_64, and armv7l - instead of disabling optimizations via ccsafe (which included sed expression 's/ -march=[^ ]* / /g;s/ -maes / /g;s/ -msse4[.]1 / /g;s/ -Xarch_[^ ]* / /g')

@stemann stemann force-pushed the feature/abseil_cpp_20230125.0 branch 3 times, most recently from 7485bb6 to f8ce470 Compare February 24, 2025 09:50
@stemann stemann force-pushed the feature/abseil_cpp_20230125.0 branch from f8ce470 to 951319c Compare February 24, 2025 10:17
@stemann stemann marked this pull request as ready for review February 24, 2025 10:17
# Avoid problems with `-march`, `-ffast-math` etc.
sed -i -e 's!set(CMAKE_C_COMPILER.*!set(CMAKE_C_COMPILER '${WORKSPACE}/srcdir/files/ccsafe')!' ${CMAKE_TARGET_TOOLCHAIN}
sed -i -e 's!set(CMAKE_CXX_COMPILER.*!set(CMAKE_CXX_COMPILER '${WORKSPACE}/srcdir/files/c++safe')!' ${CMAKE_TARGET_TOOLCHAIN}
if [[ "$target" == aarch64-* # Never apply `-march=armv8-a+crypto` -- even for aarch64-*-march+armv8_2_crypto
Copy link
Contributor Author

@stemann stemann Feb 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is probably wrong.

It would likely be better to

  • either not expand microarchs for aarch64 (as the compiled code is the same)
  • or add a patch to the compiler wrappers to allow -march flags (for aarch64 only)

Suggestions?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Abseil doesn't seem to be a performance-critical library. It would make sense to not expand microarchitectures and just use the default that we're using for all other packages.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True. The counterargument is that abseil seems to become a foundational dependency of many C++ packages, so it seems right to build it without (too many) patches - to have the "proper" thing at the base...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you distinguish between different microarchitectures then you need to make sure that this does not affect the ABI.

For example, on x86_64, if there is a function that accepts SIMD values, then the way in which they are passed depends on the microarchitecture settings. That forces all downstream packages to also be built in different versions, for different microarchitectures. Other packages (e.g. FFTW, OpenBLAS) have an ABI that is microarchitecture-independent, so this isn't a problem there. Of course, FFTW can then just make that distinction by itself at run time and thus you don't need to build different versions.

You could look at other package managers. For example, how does Debian or Ubuntu distribute Abseil? That's probably a safe choice to follow.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On a related note (no. 1), should the -march=armv8-a+crypto be allowed for aarch64 in this specific case? (patching the compiler wrapper)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On a related note (no. 2), should the BBB compiler wrappers complain (warn or error) about flags like -mfpu=neon, -maes, and -msse4.1?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there is a run-time check whether the hardware supports these CPU instructions then it's okay to compile the code, because it will not randomly crash at run time. If the code is used unconditionally then you should rely on the default architecture flags that BinaryBuilder is using, i.e. in this case you probably shouldn't be using any -march flags. Note that Julia uses compiler wrappers that inject extra compiler flags when you're building.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added sed-based patching of compiler wrappers to explicitly allow compiler arg. -march=armv8-a+crypto

…h64-apple-darwin is only expanded to aarch64-apple-darwin-march+armv8_0, and not aarch64-apple-darwin-march+armv8_2_crypto as expected.
@stemann stemann requested a review from giordano February 24, 2025 12:39
@stemann stemann mentioned this pull request Feb 24, 2025
@stemann stemann marked this pull request as draft February 24, 2025 23:45
@stemann stemann marked this pull request as ready for review February 24, 2025 23:46
@stemann stemann force-pushed the feature/abseil_cpp_20230125.0 branch from 8f98528 to 7c5fd6e Compare February 25, 2025 00:03
Comment on lines +24 to +27
# Allow setting "-march=armv8-a+crypto"
find $(dirname $(which $CC)) -type f \
| xargs grep --files-with-matches 'BinaryBuilder: Cannot force an architecture via -march' \
| xargs -n1 sed -i -E 's/^if \[\[ (" \$\{ARGS\[@\]\} " == \*"-march="\*) \]\]; then/if [[\n \1\n \&\& ! " \${ARGS[@]} " == *"-march=armv8-a+crypto"*\n]]; then/'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit confused: aren't you patching the CMake file not to set -march=armv8-a+crypto?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I’m just patching it for x86_64-apple-darwin - which is just to remedy some slightly opaque cmake configuration mess from upstream which causes the ARM64 flag to be applied for x86_64-apple-darwin.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

… and the X64 flags to be applied for aarch64-apple-darwin 🔀

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That sounds like an upstream bug?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I believe so… but not sure if this version is open for patches (wrt. upstreaming).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

20230125 is past the two year due date, so I would not expect patches upstream to be handled.
https://abseil.io/about/releases

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Newer versions don't have this problem?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don’t know yet - my plan is to push a range of PRs to cover all abseil versions used by protobuf - this is the first:

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It definitely looks like they figured out something was bad around July 2024: abseil/abseil-cpp#1710

@giordano giordano merged commit 8e9093b into JuliaPackaging:master Feb 27, 2025
30 checks passed
@stemann stemann deleted the feature/abseil_cpp_20230125.0 branch May 1, 2025 09:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants