gcc.target/i386/builtin_target.c currently FAILs on Solaris/x86 (and also on on *86*-*-freebsd*, judging from testresults):
FAIL: gcc.target/i386/builtin_target.c (test for excess errors) WARNING: gcc.target/i386/builtin_target.c compilation failed to produce executable Excess errors: Undefined first referenced symbol in file __cpu_indicator_init /var/tmp//ccj7aaTp.o ld: fatal: symbol referencing errors. No output written to . The problem is that the test is run on all i?86/x86_64 targets, but i386-cpuinfo.c is only added to libgcc on a select smaller set of targets, only those using glibc, it seems. AFAICS there's nothing glibc-specific in that file (with the possible exection of constructor priority, which might depend on gld), so I suggest to use it everywhere. In order for this to work, one needs to check if init priority is supported by the toolchain used, otherwise i386-cpuinfo.c will fail to compile. It seems that the only thing you loose if it's not is the ability to use __builtin_cpu_* in constructors without explicitly calling __builtin_cpu_init, which seems like an acceptable limitation if documented (not yet in this patch). I'm now introducing a config header for libgcc to contain the test results, but to avoid clashes with the (still used) headers in gcc, I'm calling it auto-target.h (like gcc's auto-host.h). Makefile.in still contained references to the generic config.h, but that file doesn't exist, so I've reused them for auto-target.h. Bootstrapped without regressions on i386-pc-solaris2.11 (as/ld, gas/ld, gas/gld). Ok for mainline? Rainer 2012-04-26 Rainer Orth <r...@cebitec.uni-bielefeld.de> libgcc: * config.host (i[34567]86-*-linux*, x86_64-*-linux*) (i[34567]86-*-kfreebsd*-gnu, x86_64-*-kfreebsd*-gnu) (i[34567]86-*-knetbsd*-gnu, i[34567]86-*-gnu*): Move i386/t-cpuinfo ... (i[34567]86-*-*, x86_64-*-*): ... here. * config/i386/libgcc-bsd.ver (GCC_4.8.0): New version. * config/i386/libgcc-sol2.ver (GCC_4.8.0): New version. * config/i386/i386-cpuinfo.c: Rename to ... * config/i386/cpuinfo.c: ... this. * config/i386/t-cpuinfo (LIB2ADD): Reflect this. * configure.ac (AC_CONFIG_HEADER): Call for auto-target.h. (libgcc_cv_init_priority): New test. * configure: Regenerate. * config.in: New file. * Makefile.in (clean): Rename config.h to auto-target.h. (config.h): Likewise. (stamp-h): Likewise. * config/i386/cpuinfo.c (auto-target.h): Include. (CONSTRUCTOR_PRIORITY): Define. (__cpu_indicator_init): Use it. gcc * config/i386/i386.c: Update comments for i386-cpuinfo.c name change.
# HG changeset patch # Parent eab812ef23d92c2aea25c912aef933f4c8cd0d27 Use i386-cpuinfo.c on all i386 targets diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -27699,7 +27699,7 @@ ix86_init_mmx_sse_builtins (void) } /* This builds the processor_model struct type defined in - libgcc/config/i386/i386-cpuinfo.c */ + libgcc/config/i386/cpuinfo.c */ static tree build_processor_model_struct (void) @@ -27759,7 +27759,7 @@ make_var_decl (tree type, const char *na } /* FNDECL is a __builtin_cpu_is or a __builtin_cpu_supports call that is folded - into an integer defined in libgcc/config/i386/i386-cpuinfo.c */ + into an integer defined in libgcc/config/i386/cpuinfo.c */ static tree fold_builtin_cpu (tree fndecl, tree *args) @@ -27769,8 +27769,7 @@ fold_builtin_cpu (tree fndecl, tree *arg DECL_FUNCTION_CODE (fndecl); tree param_string_cst = NULL; - /* This is the order of bit-fields in __processor_features in - i386-cpuinfo.c */ + /* This is the order of bit-fields in __processor_features in cpuinfo.c */ enum processor_features { F_CMOV = 0, @@ -27788,7 +27787,7 @@ fold_builtin_cpu (tree fndecl, tree *arg }; /* These are the values for vendor types and cpu types and subtypes - in i386-cpuinfo.c. Cpu types and subtypes should be subtracted by + in cpuinfo.c. Cpu types and subtypes should be subtracted by the corresponding start value. */ enum processor_model { diff --git a/libgcc/Makefile.in b/libgcc/Makefile.in --- a/libgcc/Makefile.in +++ b/libgcc/Makefile.in @@ -121,7 +121,7 @@ installcheck: .PHONY: all clean clean: - -rm -f config.h libgcc_tm.h stamp-h stmp-ldirs libgcc.map + -rm -f auto-target.h libgcc_tm.h stamp-h stmp-ldirs libgcc.map -rm -f *$(objext) -rm -f *.dep -rm -f *.a @@ -139,9 +139,9 @@ Makefile: $(srcdir)/Makefile.in config.s # Depending on Makefile makes sure that config.status has been re-run # if needed. This prevents problems with parallel builds. -config.h: stamp-h ; @true +auto-target.h: stamp-h ; @true stamp-h: $(srcdir)/config.in config.status Makefile - CONFIG_FILES= CONFIG_HEADERS=config.h:$(srcdir)/config.in $(SHELL) ./config.status + CONFIG_FILES= CONFIG_HEADERS=auto-target.h:$(srcdir)/config.in $(SHELL) ./config.status config.status: $(srcdir)/configure $(srcdir)/config.host $(SHELL) ./config.status --recheck diff --git a/libgcc/config.host b/libgcc/config.host --- a/libgcc/config.host +++ b/libgcc/config.host @@ -1124,11 +1124,17 @@ mep*-*-*) esac case ${host} in +i[34567]86-*-* | x86_64-*-*) + tmake_file="${tmake_file} i386/t-cpuinfo" + ;; +esac + +case ${host} in i[34567]86-*-linux* | x86_64-*-linux* | \ i[34567]86-*-kfreebsd*-gnu | x86_64-*-kfreebsd*-gnu | \ i[34567]86-*-knetbsd*-gnu | \ i[34567]86-*-gnu*) - tmake_file="${tmake_file} t-tls i386/t-linux i386/t-cpuinfo" + tmake_file="${tmake_file} t-tls i386/t-linux" if test "$libgcc_cv_cfi" = "yes"; then tmake_file="${tmake_file} t-stack i386/t-stack-i386" fi diff --git a/libgcc/config/i386/i386-cpuinfo.c b/libgcc/config/i386/cpuinfo.c rename from libgcc/config/i386/i386-cpuinfo.c rename to libgcc/config/i386/cpuinfo.c --- a/libgcc/config/i386/i386-cpuinfo.c +++ b/libgcc/config/i386/cpuinfo.c @@ -20,8 +20,16 @@ along with GCC; see the file COPYING3. #include "cpuid.h" #include "tsystem.h" +#include "auto-target.h" -int __cpu_indicator_init (void) __attribute__ ((constructor (101))); +#ifdef HAVE_INIT_PRIORITY +#define CONSTRUCTOR_PRIORITY (101) +#else +#define CONSTRUCTOR_PRIORITY +#endif + +int __cpu_indicator_init (void) + __attribute__ ((constructor CONSTRUCTOR_PRIORITY)); enum vendor_signatures { @@ -253,7 +261,7 @@ __get_cpuid_output (unsigned int __level the priority set. However, it still runs after ifunc initializers and needs to be called explicitly there. */ -int __attribute__ ((constructor (101))) +int __attribute__ ((constructor CONSTRUCTOR_PRIORITY)) __cpu_indicator_init (void) { unsigned int eax, ebx, ecx, edx; diff --git a/libgcc/config/i386/libgcc-bsd.ver b/libgcc/config/i386/libgcc-bsd.ver --- a/libgcc/config/i386/libgcc-bsd.ver +++ b/libgcc/config/i386/libgcc-bsd.ver @@ -1,4 +1,4 @@ -# Copyright (C) 2010 Free Software Foundation, Inc. +# Copyright (C) 2010, 2012 Free Software Foundation, Inc. # # This file is part of GCC. # @@ -106,3 +106,7 @@ GCC_4.6.0 { __trunctfxf2 __unordtf2 } + +GCC_4.8.0 { + __cpu_model +} diff --git a/libgcc/config/i386/libgcc-glibc.ver b/libgcc/config/i386/libgcc-glibc.ver --- a/libgcc/config/i386/libgcc-glibc.ver +++ b/libgcc/config/i386/libgcc-glibc.ver @@ -1,4 +1,4 @@ -# Copyright (C) 2008, 2010 Free Software Foundation, Inc. +# Copyright (C) 2008, 2010, 2012 Free Software Foundation, Inc. # # This file is part of GCC. # diff --git a/libgcc/config/i386/libgcc-sol2.ver b/libgcc/config/i386/libgcc-sol2.ver --- a/libgcc/config/i386/libgcc-sol2.ver +++ b/libgcc/config/i386/libgcc-sol2.ver @@ -1,4 +1,4 @@ -# Copyright (C) 2010 Free Software Foundation, Inc. +# Copyright (C) 2010, 2012 Free Software Foundation, Inc. # # This file is part of GCC. # @@ -106,3 +106,7 @@ GCC_4.5.0 { __trunctfxf2 __unordtf2 } + +GCC_4.8.0 { + __cpu_model +} diff --git a/libgcc/config/i386/t-cpuinfo b/libgcc/config/i386/t-cpuinfo --- a/libgcc/config/i386/t-cpuinfo +++ b/libgcc/config/i386/t-cpuinfo @@ -1,1 +1,1 @@ -LIB2ADD += $(srcdir)/config/i386/i386-cpuinfo.c +LIB2ADD += $(srcdir)/config/i386/cpuinfo.c diff --git a/libgcc/configure.ac b/libgcc/configure.ac --- a/libgcc/configure.ac +++ b/libgcc/configure.ac @@ -39,6 +39,7 @@ else fi AC_SUBST(libgcc_topdir) AC_CONFIG_AUX_DIR($libgcc_topdir) +AC_CONFIG_HEADER(auto-target.h:config.in) AC_ARG_ENABLE(shared, [ --disable-shared don't provide a shared libgcc], @@ -327,6 +328,15 @@ if test "$enable_tls $gcc_cv_use_emutls" fi AC_SUBST(set_use_emutls) +AC_CACHE_CHECK(for init priority support, libgcc_cv_init_priority, [ +AC_COMPILE_IFELSE([AC_LANG_PROGRAM(, + [[void ip (void) __attribute__ ((constructor (1)));]])], + [libgcc_cv_init_priority=yes],[libgcc_cv_init_priority=no])]) +if test $libgcc_cv_init_priority = yes; then + AC_DEFINE(HAVE_INIT_PRIORITY, 1, + [Define if the compiler supports init priority.]) +fi + # Conditionalize the sfp-machine.h header for this target machine. if test -z "${sfp_machine_header}"; then sfp_machine_header=$cpu_type/sfp-machine.h
-- ----------------------------------------------------------------------------- Rainer Orth, Center for Biotechnology, Bielefeld University