Skip to content
This repository has been archived by the owner on Jan 16, 2025. It is now read-only.

gcc.rb: fix libgccjit linker flags #42924

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions Library/Formula/gcc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -257,3 +257,23 @@ def caveats

$(LIBGCCJIT_SONAME_SYMLINK): $(LIBGCCJIT_FILENAME)
ln -sf $(LIBGCCJIT_FILENAME) $(LIBGCCJIT_SONAME_SYMLINK)
diff --git a/gcc/jit/jit-playback.c b/gcc/jit/jit-playback.c
index 925fa86..01cfd4b 100644
--- a/gcc/jit/jit-playback.c
+++ b/gcc/jit/jit-playback.c
@@ -2416,6 +2416,15 @@ invoke_driver (const char *ctxt_progname,
time. */
ADD_ARG ("-fno-use-linker-plugin");

+#if defined (DARWIN_X86) || defined (DARWIN_PPC)
+ /* OS X's linker defaults to treating undefined symbols as errors.
+ If the context has any imported functions or globals they will be
+ undefined until the .so is dynamically-linked into the process.
+ Ensure that the driver passes in "-undefined dynamic_lookup" to the
+ linker. */
+ ADD_ARG ("-Wl,-undefined,dynamic_lookup");
+#endif
+
/* pex argv arrays are NULL-terminated. */
argvec.safe_push (NULL);