When I compile with bazel on MacOS, unresolved symbols do NOT produce a build-time error, and instead produce a runtime error:
As a result, I get runtime errors with 0 useful information:
dyld[10951]: missing symbol called
There is no indication whatsoever what the missing symbol is. I love my builds being reliable, and this is not something I'm comfortable with pushing to prod.
After a fair bit of debugging, I traced it down to -undefined dynamic_lookup being passed to the linker by default, and it's something I'd like to disable.
One way to do so in a non-portable matter is to add linkopts = ["-undefined error"] to my targets. A more portable way is more complex:
linkopts = select({
"@platforms//os:macos": ["-undefined error"],
"//conditions:default": [],
}),
And I'd prefer something that didn't involve adding these 4 lines to all of my targets, but also without changes to the ~/.bazelrc. Thanks!