Skip to content

Conversation

TeddyRandby
Copy link

Fix #17554

When initializing the gc_sections flag in the MachO linker, check the config's rdynamic setting. Don't eliminate dead code in non-debug builds when rdynamic is set (Unless gc_sections itself is explicitly set).

I tested locally on a c file such as this:

int example(int a, int b) { return a + b; }

int main() { return 0; }

Cross-compiling for macos like so:

~/repos/zig/stage3/bin/zig cc -O3 -rdynamic main.c -o main --target=aarch64-macos-none

Using llvm-objdump -S main, I can confirm that:

  • the example function is eliminated in -O3
  • the example function is present in -O3 -rdynamic.

This is my first open source contribution, let me know if anything needs to be fixed!

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.

rdynamic = true has no effect on Mach-O ld linker

1 participant