From a96996a1827d0a6a5c7f7f1aa730e03665ba9231 Mon Sep 17 00:00:00 2001 From: Peter Wemm Date: Fri, 13 Jun 2003 22:25:41 +0000 Subject: [PATCH] When building a shared library, link it against libgcc_pic.a instead of the non-PIC libgcc.a. Linking non-pic code into a shared library is not a good thing. It happens to break amd64 at compile time, and the ppc folks want it too. The problem is mainly with C++ code, unwind-dw2.c in particular. Most of the other functions in libgcc.a are self contained so most of the time it isn't a problem. The dwarf2 unwinder is not safe though since it does make global variable references. Reviewed by: kan --- gnu/usr.bin/cc/cc_tools/freebsd-native.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gnu/usr.bin/cc/cc_tools/freebsd-native.h b/gnu/usr.bin/cc/cc_tools/freebsd-native.h index a102a89a298b..cde8d89dbd46 100644 --- a/gnu/usr.bin/cc/cc_tools/freebsd-native.h +++ b/gnu/usr.bin/cc/cc_tools/freebsd-native.h @@ -48,7 +48,8 @@ /* For the native system compiler, we actually build libgcc in a profiled version. So we should use it with -pg. */ -#define LIBGCC_SPEC "%{!pg: -lgcc} %{pg: -lgcc_p}" +#define LIBGCC_SPEC "%{shared: -lgcc_pic} \ + %{!shared: %{!pg: -lgcc} %{pg: -lgcc_p}}" #define LIBSTDCXX_PROFILE "-lstdc++_p" #define MATH_LIBRARY_PROFILE "-lm_p" #define FORTRAN_LIBRARY_PROFILE "-lg2c_p"