-
Notifications
You must be signed in to change notification settings - Fork 0
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
fix: various mac build fixes and improvements [DIP-311] #112
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jungleraptor
force-pushed
the
isaac/mac-fixes
branch
from
October 4, 2023 23:34
3850444
to
1bb4158
Compare
swiftnav-svc-jenkins
force-pushed
the
isaac/mac-fixes
branch
from
October 5, 2023 04:03
1bb4158
to
a0dcfdf
Compare
jungleraptor
changed the title
wip: fix: various mac build fixes and improvements [DIP-311]
fix: various mac build fixes and improvements [DIP-311]
Oct 5, 2023
silverjam
reviewed
Oct 5, 2023
silverjam
approved these changes
Oct 6, 2023
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.
Pending anymore testing you'd like to do
Test PR's are passing so I'm going to merge |
jungleraptor
force-pushed
the
isaac/mac-fixes
branch
from
October 6, 2023 03:01
6bfc901
to
26fffa3
Compare
jungleraptor
force-pushed
the
isaac/mac-fixes
branch
from
October 6, 2023 03:03
26fffa3
to
729f164
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The recent macos sdk v15 update has caused a number of issues with our builds that require various tweaks to our build settings to fix.
Switch to ninja for cmake generator
The
cmake
build process involves bootstrapping a gnu make binary from source. The update has caused some strange build errors during this process. More info can be found in the ticket I've created here: bazel-contrib/rules_foreign_cc#1099In the meantime we can just switch to using the ninja generator.
Drop support for shared linking
We make liberal use of "weak linking" for various purposes across the codebase - usually implemented using function pointers for (I assume) portability.
However, this means that most of our libraries can't really be built as shared libraries due to resulting "undefined reference" errors.
In bazel the build system will by default always try to build the shared library unless
linkstatic
is set toTrue
. So on mac this was causing errors during the normal build. Not sure why linux was not having problems (all our CMake builds fail when-DBUILD_SHARED_LIBS=TRUE
).To fix this I added
-undefined dynamic_lookup
to the link flags on mac to tell the linker we'll supply the symbols later at the final link step.Now with the update, for whatever reason these flags appear to be causing the following crash on m1 macs when the linker tries to link a binary:
Since we've never really supported shared linking except in some exceptional cases, I've disabled shared library builds by default across all our code and thus can remove the problematic flags (and probably get a perf boost as well).
Make the minimum macos target consistent
Another annoyance with the mac builds was that the bazel code was getting compiled with a different macos deployment target than the cmake libraries, which resulting in the build output getting spammed with linker warnings referencing this difference.
On my system the bazel target was
13.0
, while the cmake value was13.6
. I'm not sure how (as of our current version of bazel 6.2) this value is computed.In CMake it's interpolated from the system.
To fix this I've wired up our toolchain to respect the macos_minimum_os flags and add
-mmacos-version-min
to our build. This is just taken from the most recentHEAD
ofbazel
which is not in 6.x.The CMake side requires explicitly setting CMAKE_OSX_DEPLOYMENT_TARGET variable to the same value.
It would be better if
rules_foreign_cc
also respected themacos_minimum_os
flag so the value would not have to be hardcoded. We can perhaps open a ticket to request this.13.0
seems like a reasonable minimum deployment target since these builds are only intended for development machines.Testing
I've tested these changes on m1 and intel macs as well as the following test PR's: