Currently, the libasan shared library in FSF gcc is linked without the 
Foundation framework
on darwin...

% otool -L /sw/lib/gcc4.9/lib/libasan.1.dylib
/sw/lib/gcc4.9/lib/libasan.1.dylib:
        /sw/lib/gcc4.9/lib/libasan.1.dylib (compatibility version 2.0.0, 
current version 2.0.0)
        /sw/lib/gcc4.9/lib/libstdc++.6.dylib (compatibility version 7.0.0, 
current version 7.19.0)
        /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current 
version 169.3.0)
        /sw/lib/gcc4.9/lib/libgcc_s.1.dylib (compatibility version 1.0.0, 
current version 1.0.0)

compared to llvm svn...

% otool -L 
/sw/opt/llvm-3.4/lib/clang/3.4/lib/darwin/libclang_rt.asan_osx_dynamic.dylib
/sw/opt/llvm-3.4/lib/clang/3.4/lib/darwin/libclang_rt.asan_osx_dynamic.dylib:
        
/sw/opt/llvm-3.4/lib/clang/3.4/lib/darwin/libclang_rt.asan_osx_dynamic.dylib 
(compatibility version 0.0.0, current version 0.0.0)
        /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation 
(compatibility version 300.0.0, current version 945.18.0)
        /usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current 
version 56.0.0)
        /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current 
version 169.3.0)

The attached patch adds the missing linkage of the Foundation framework to 
libasan_la_LDFLAGS
which produces the desired linkage of...

% otool -L /sw/lib/gcc4.9/lib/libasan.1.dylib
/sw/lib/gcc4.9/lib/libasan.1.dylib:
        /sw/lib/gcc4.9/lib/libasan.1.dylib (compatibility version 2.0.0, 
current version 2.0.0)
        /sw/lib/gcc4.9/lib/libstdc++.6.dylib (compatibility version 7.0.0, 
current version 7.19.0)
        /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation 
(compatibility version 300.0.0, current version 945.18.0)
        /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current 
version 169.3.0)
        /sw/lib/gcc4.9/lib/libgcc_s.1.dylib (compatibility version 1.0.0, 
current version 1.0.0)

Bootstrap and regression tested on x86_64-apple-darwin12 against Xcode 5.0.1 at 
r204750. 

Native configuration is x86_64-apple-darwin12.5.0

                === g++ tests ===


Running target unix/-m32

                === g++ Summary for unix/-m32 ===

# of expected passes            481
# of unsupported tests          132

Running target unix/-m64

                === g++ Summary for unix/-m64 ===

# of expected passes            481
# of unsupported tests          132

                === g++ Summary ===

# of expected passes            962
# of unsupported tests          264
/sw/src/fink.build/gcc49-4.9.0-1000/darwin_objdir/gcc/testsuite/g++/../../xg++  
version 4.9.0 20131113 (experimental) (GCC) 

                === gcc tests ===


Running target unix/-m32

                === gcc Summary for unix/-m32 ===

# of expected passes            326
# of unsupported tests          101

Running target unix/-m64

                === gcc Summary for unix/-m64 ===

# of expected passes            326
# of unsupported tests          101

                === gcc Summary ===

# of expected passes            652
# of unsupported tests          202
/sw/src/fink.build/gcc49-4.9.0-1000/darwin_objdir/gcc/xgcc  version 4.9.0 
20131113 (experimental) (GCC) 

Compiler version: 4.9.0 20131113 (experimental) (GCC) 
Platform: x86_64-apple-darwin12.5.0
configure flags: --prefix=/sw --prefix=/sw/lib/gcc4.9 --mandir=/sw/share/man 
--infodir=/sw/lib/gcc4.9/info 
--enable-languages=c,c++,fortran,lto,objc,obj-c++,java --with-gmp=/sw 
--with-libiconv-prefix=/sw --with-isl=/sw --with-cloog=/sw --with-mpc=/sw 
--with-system-zlib --enable-checking=yes --x-includes=/usr/X11R6/include 
--x-libraries=/usr/X11R6/lib --program-suffix=-fsf-4.9

   This change is sufficient to suppress the failures in sanitizer/PR58994 at 
-m64. Okay for
gcc trunk after libsanitizer is synced with the alternative fix from

http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20131111/194748.html

so that we are following the norms for linkage on darwin and adhere closer to 
the llvm
libsanitizer build approach for libasan?
                   Jack
ps Note that "-Wl,-framework,Foundation" is used to prevent libtool from 
munging the
the flags.

libsanitizer/

2013-11-13  Jack Howarth  <howa...@bromo.med.uc.edu>

        PR sanitizer/58994
        * asan/Makefile.am (libasan_la_LDFLAGS): Link to Foundation framework 
on darwin.
        * asan/Makefile.in: Regenerate.


Index: libsanitizer/asan/Makefile.am
===================================================================
--- libsanitizer/asan/Makefile.am       (revision 204750)
+++ libsanitizer/asan/Makefile.am       (working copy)
@@ -43,7 +43,11 @@ libasan_la_LIBADD = $(top_builddir)/sani
 endif
 libasan_la_LIBADD += $(LIBSTDCXX_RAW_CXX_LDFLAGS)
 
+if USING_MAC_INTERPOSE
+libasan_la_LDFLAGS = -version-info `grep -v '^\#' $(srcdir)/libtool-version` 
-Wl,-framework,Foundation -lpthread -ldl
+else
 libasan_la_LDFLAGS = -version-info `grep -v '^\#' $(srcdir)/libtool-version` 
-lpthread -ldl
+endif
 
 libasan_preinit.o: asan_preinit.o
        cp $< $@
libsanitizer/

2013-11-13  Jack Howarth  <howa...@bromo.med.uc.edu>

        PR sanitizer/58994
        * asan/Makefile.am (libasan_la_LDFLAGS): Link to Foundation framework 
on darwin.
        * asan/Makefile.in: Regenerate.

Index: libsanitizer/asan/Makefile.am
===================================================================
--- libsanitizer/asan/Makefile.am       (revision 204750)
+++ libsanitizer/asan/Makefile.am       (working copy)
@@ -43,7 +43,11 @@ libasan_la_LIBADD = $(top_builddir)/sani
 endif
 libasan_la_LIBADD += $(LIBSTDCXX_RAW_CXX_LDFLAGS)
 
+if USING_MAC_INTERPOSE
+libasan_la_LDFLAGS = -version-info `grep -v '^\#' $(srcdir)/libtool-version` 
-Wl,-framework,Foundation -lpthread -ldl
+else
 libasan_la_LDFLAGS = -version-info `grep -v '^\#' $(srcdir)/libtool-version` 
-lpthread -ldl
+endif
 
 libasan_preinit.o: asan_preinit.o
        cp $< $@

Reply via email to