From 1b7afeb0fad6419328546a0dcdbb0431f870023c Mon Sep 17 00:00:00 2001 From: David Malcolm Date: Thu, 13 Aug 2015 21:18:50 -0400 Subject: [PATCH] gcc.rb: fix libgccjit linker flags This patch to homebrew adds a patch needed by libgccjit on OS X that I've committed to upstream gcc here: https://gcc.gnu.org/ml/jit/2015-q3/msg00148.html I've not personally tested it (I don't have an OS X box), but it is identical to the one posted here, reported as necessary: https://gcc.gnu.org/ml/jit/2015-q3/msg00147.html --- Library/Formula/gcc.rb | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Library/Formula/gcc.rb b/Library/Formula/gcc.rb index b253f9458145..3c1e983aa685 100644 --- a/Library/Formula/gcc.rb +++ b/Library/Formula/gcc.rb @@ -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); +