-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Check for CMAKE_C_COMPILER_ID not CXX #64226
Check for CMAKE_C_COMPILER_ID not CXX #64226
Conversation
In some cases, CMAKE_CXX_COMPILER_ID might not be populated, which causes the toolchaine prefix checks to be ignored, which causes the build to look for `ranlib` not `llvm-ranlib`, which causes it to use XCode ranlib instead of Android NDK ranlib for builds, which doesn't work. Hopefully (we'll see what CI says) this doesn't regress other builds. Closes: dotnet#55412
I couldn't figure out the best area label to add to this PR. If you have write-permissions please help me learn by adding exactly one area label. |
cc @am11 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Co-authored-by: Adeel Mujahid <[email protected]>
Failing lane is an unrelated timeout issue, will do a separate PR to make that one not run on PR |
…rt-is-moderately-cursed
…rt-is-moderately-cursed
It's available in r21 (which we use today) and works for r23 (which has no GNU objcopy any more and breaks without this change)
@jkotas, @directhex, looking at it again with fresh eyes I just remember making this ditto change in the past ba50840 to use "correct" objcopy. Unfortunately, it caused binary size regression and ultimately we had to revert it. The issue was that on my local system (Ubuntu) I was using llvm-10 at the time but on build systems, we were (and still are) using llvm-9 in most cases. There is a bug in llvm-9 objcopy which fails to strip the symbols. LLVM 10 onwards has that bug fixed (it was never backported). Therefore, I think we should hold this until we update official baseline to clang 10 or above, and continue to use GNU's objcopy instead of LLVM9's one. |
@am11 this is only using llvm-objcopy from the Android NDK, not in general. Do you know where in the LLVM tree objcopy was fixed? I can check the Android repo to see if Google patched it downstream in their llvm 9 (NDK r21) |
@directhex, the effect was on objcopy but the change was exactly what you have |
@am11 I can't reproduce that. Using mcr.microsoft.com/dotnet-buildtools/prereqs:centos-7-20210714125435-9b5bbc2, on git master:
this branch:
Looking at the build logs and CMake output, Actually, looking even closer, the core behaviour here is:
The reasoning given in #49092 for the revert is definitely the linux-x64 case |
Cool. Thanks for confirming it. We can update it to also use matching/correct toolchain, once baseline is updated to clang 10 or beyond. |
Do we have a CI lane to check for size regression? Because I don't see how this change ever affected the build in the way reported in #49092 |
Not sure if there is such a lane, but there is a label to that effect: https://github.com/dotnet/runtime/issues?q=is:open+is:issue+label:size-reduction. I think in this case, the shipping installer package (which includes runtimes+sdks+templates) was manually compared with the previous release at the time. Similar inspection is done for file count differences in packages near the releases to prevent unintended files from getting shipped (or find missing essential files or even duplicate files in nuget packages). Some of those targets are automated and run only during the official builds AFAIK. |
Technically the behavior does change for runtime/src/native/libs/CMakeLists.txt Line 18 in 5a9bcde
In this case, cmake only locates and activates C toolchain and CMAKE_CXX_COMPILER_ID is empty string, but CMAKE_C_COMPILER_ID has a value.
|
Okay, it seems it does have an effect on libs.native - for But it still uses GNU |
@am11 can I have an approval, if you're confident with my analyses of the file size concern? Is there someone else we should ask? |
LGTM, thank you! cc @janvorli |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thank you!
In some cases,
CMAKE_CXX_COMPILER_ID
might not be populated, which causes the toolchain prefix checks to be ignored, which causes the build to look forranlib
notllvm-ranlib
, which causes it to use XCoderanlib
instead of Android NDKranlib
for builds, which doesn't work.Hopefully (we'll see what CI says) this doesn't regress other builds.
Closes: #55412