From 0b6e3127e8a003ad01b9cfb6896dee14c637701b Mon Sep 17 00:00:00 2001 From: Rainer Orth Date: Thu, 14 Feb 2019 17:47:49 +0000 Subject: [PATCH] Provide __start_minfo/__stop_minfo for linkers that don't (PR d/87864) libphobos: PR d/87864 * configure.ac (DRTSTUFF_SPEC): New variable. Substitute it. * libdruntime/m4/druntime/os.m4 (DRUNTIME_OS_MINFO_BRACKETING): New automake conditional. * configure: Regenerate. * libdruntime/gcc/drtstuff.c: New file. * libdruntime/Makefile.am [!DRUNTIME_OS_MINFO_BRACKETING] (DRTSTUFF, toolexeclib_DATA): New variables. (gcc/drtbegin.lo, gcc/drtend.lo): New rules. (libgdruntime_la_LDFLAGS): Use -Wc instead of -Xcompiler. Add -dstartfiles -B../src -Bgcc. (libgdruntime_la_DEPENDENCIES): New variable. (unittest_static_LDFLAGS): Use -Wc instead of -Xcompiler. (libgdruntime_t_la_LDFLAGS): Likewise. (unittest_LDFLAGS): Likewise. * src/Makefile.am (libgphobos_la_LDFLAGS): Use -Wc instead of -Xcompiler. Add -dstartfiles -B../libdruntime/gcc. (unittest_static_LDFLAGS): Use -Wc instead of -Xcompiler. (libgphobos_t_la_LDFLAGS): Likewise. (unittest_LDFLAGS): Likewise. * libdruntime/Makefile.in, src/Makefile.in: Regenerate. * Makefile.in, testsuite/Makefile.in: Regenerate. * libdruntime/rt/sections_elf_shared.d (Minfo_Bracketing): Don't assert. * libdruntime/gcc/config.d.in (Minfo_Bracketing): Remove. * src/drtstuff.spec: New file. * src/libgphobos.spec.in (DRTSTUFF_SPEC): Substitute. (*lib): Only pass SPEC_PHOBOS_DEPS without -debuglib, -defaultlib, -nophoboslib. * testsuite/testsuite_flags.in <--gdcldflags> (GDCLDFLAGS): Add -B${BUILD_DIR}/libdruntime/gcc. gcc/d: PR d/87864 * lang.opt (dstartfiles): New option. * d-spec.cc (need_spec): New variable. (lang_specific_driver) : Enable need_spec. (lang_specific_pre_link): Also load libgphobos.spec if need_spec. gcc/testsuite: PR d/87864 * lib/gdc.exp (gdc_link_flags): Add path to drtbegin.o/drtend.o if present. From-SVN: r268886 --- gcc/d/ChangeLog | 8 ++ gcc/d/d-spec.cc | 9 +- gcc/d/lang.opt | 4 + gcc/testsuite/ChangeLog | 6 ++ gcc/testsuite/lib/gdc.exp | 4 + libphobos/ChangeLog | 36 ++++++++ libphobos/configure | 86 ++++++++++++++++--- libphobos/configure.ac | 8 ++ libphobos/libdruntime/Makefile.am | 24 +++++- libphobos/libdruntime/Makefile.in | 71 +++++++++++---- libphobos/libdruntime/gcc/config.d.in | 3 - libphobos/libdruntime/gcc/drtstuff.c | 39 +++++++++ .../libdruntime/rt/sections_elf_shared.d | 1 - libphobos/m4/druntime/os.m4 | 1 + libphobos/src/Makefile.am | 9 +- libphobos/src/Makefile.in | 10 ++- libphobos/src/drtstuff.spec | 5 ++ libphobos/src/libgphobos.spec.in | 4 +- libphobos/testsuite/testsuite_flags.in | 1 + 19 files changed, 283 insertions(+), 46 deletions(-) create mode 100644 libphobos/libdruntime/gcc/drtstuff.c create mode 100644 libphobos/src/drtstuff.spec diff --git a/gcc/d/ChangeLog b/gcc/d/ChangeLog index 151fe1c6ab1..6eb2ac488e6 100644 --- a/gcc/d/ChangeLog +++ b/gcc/d/ChangeLog @@ -1,3 +1,11 @@ +2019-02-14 Rainer Orth + + PR d/87864 + * lang.opt (dstartfiles): New option. + * d-spec.cc (need_spec): New variable. + (lang_specific_driver) : Enable need_spec. + (lang_specific_pre_link): Also load libgphobos.spec if need_spec. + 2019-01-26 Iain Buclaw PR d/89042 diff --git a/gcc/d/d-spec.cc b/gcc/d/d-spec.cc index 724e5d2f5d4..3d491f56fa7 100644 --- a/gcc/d/d-spec.cc +++ b/gcc/d/d-spec.cc @@ -72,6 +72,9 @@ static phobos_action phobos_library = PHOBOS_DEFAULT; standard libraries. */ static bool need_phobos = true; +/* If true, do load libgphobos.spec even if not needed otherwise. */ +static bool need_spec = false; + void lang_specific_driver (cl_decoded_option **in_decoded_options, unsigned int *in_decoded_options_count, @@ -144,6 +147,10 @@ lang_specific_driver (cl_decoded_option **in_decoded_options, switch (decoded_options[i].opt_index) { + case OPT_dstartfiles: + need_spec = true; + break; + case OPT_nostdlib: case OPT_nodefaultlibs: phobos_library = PHOBOS_NOLINK; @@ -491,7 +498,7 @@ lang_specific_driver (cl_decoded_option **in_decoded_options, int lang_specific_pre_link (void) { - if (phobos_library != PHOBOS_NOLINK && need_phobos) + if ((phobos_library != PHOBOS_NOLINK && need_phobos) || need_spec) do_spec ("%:include(libgphobos.spec)"); return 0; diff --git a/gcc/d/lang.opt b/gcc/d/lang.opt index 83d3d21a1a6..523f73c90de 100644 --- a/gcc/d/lang.opt +++ b/gcc/d/lang.opt @@ -162,6 +162,10 @@ defaultlib= Driver Joined Default library to use instead of phobos. +dstartfiles +Driver +Do link the standard D startup files in the compilation. + -verbose D Alias(v) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 4d2a2363183..bec48f2ab24 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2019-02-14 Rainer Orth + + PR d/87864 + * lib/gdc.exp (gdc_link_flags): Add path to drtbegin.o/drtend.o if + present. + 2019-02-14 Tamar Christina PR target/88850 diff --git a/gcc/testsuite/lib/gdc.exp b/gcc/testsuite/lib/gdc.exp index c749c4c055d..1bc45b92061 100644 --- a/gcc/testsuite/lib/gdc.exp +++ b/gcc/testsuite/lib/gdc.exp @@ -120,6 +120,10 @@ proc gdc_link_flags { paths } { if { $gccpath != "" } { # Path to libgphobos.spec. append flags "-B${gccpath}/libphobos/src " + # Path to drtbegin.o/drtend.o. + if { [file exists "${gccpath}/libphobos/libdruntime/gcc/drtbegin.o"] } { + append flags "-B${gccpath}/libphobos/libdruntime/gcc " + } if { [file exists "${gccpath}/libphobos/src/.libs/libgphobos.a"] \ || [file exists "${gccpath}/libphobos/src/.libs/libgphobos.${shlib_ext}"] } { diff --git a/libphobos/ChangeLog b/libphobos/ChangeLog index e43b8559d27..4efd97efaaf 100644 --- a/libphobos/ChangeLog +++ b/libphobos/ChangeLog @@ -1,3 +1,39 @@ +2019-02-14 Rainer Orth + + PR d/87864 + * configure.ac (DRTSTUFF_SPEC): New variable. + Substitute it. + * libdruntime/m4/druntime/os.m4 (DRUNTIME_OS_MINFO_BRACKETING): + New automake conditional. + * configure: Regenerate. + * libdruntime/gcc/drtstuff.c: New file. + * libdruntime/Makefile.am [!DRUNTIME_OS_MINFO_BRACKETING] + (DRTSTUFF, toolexeclib_DATA): New variables. + (gcc/drtbegin.lo, gcc/drtend.lo): New rules. + (libgdruntime_la_LDFLAGS): Use -Wc instead of -Xcompiler. + Add -dstartfiles -B../src -Bgcc. + (libgdruntime_la_DEPENDENCIES): New variable. + (unittest_static_LDFLAGS): Use -Wc instead of -Xcompiler. + (libgdruntime_t_la_LDFLAGS): Likewise. + (unittest_LDFLAGS): Likewise. + * src/Makefile.am (libgphobos_la_LDFLAGS): Use -Wc instead of + -Xcompiler. + Add -dstartfiles -B../libdruntime/gcc. + (unittest_static_LDFLAGS): Use -Wc instead of -Xcompiler. + (libgphobos_t_la_LDFLAGS): Likewise. + (unittest_LDFLAGS): Likewise. + * libdruntime/Makefile.in, src/Makefile.in: Regenerate. + * Makefile.in, testsuite/Makefile.in: Regenerate. + * libdruntime/rt/sections_elf_shared.d (Minfo_Bracketing): Don't + assert. + * libdruntime/gcc/config.d.in (Minfo_Bracketing): Remove. + * src/drtstuff.spec: New file. + * src/libgphobos.spec.in (DRTSTUFF_SPEC): Substitute. + (*lib): Only pass SPEC_PHOBOS_DEPS without -debuglib, -defaultlib, + -nophoboslib. + * testsuite/testsuite_flags.in <--gdcldflags> (GDCLDFLAGS): Add + -B${BUILD_DIR}/libdruntime/gcc. + 2019-02-13 Iain Buclaw * libdruntime/core/runtime.d (defaultTraceHandler): Give diff --git a/libphobos/configure b/libphobos/configure index 9f96ad5d190..4741c287a44 100755 --- a/libphobos/configure +++ b/libphobos/configure @@ -3,7 +3,7 @@ # Generated by GNU Autoconf 2.69 for package-unused version-unused. # # -# Copyright (C) 1992-2019 Free Software Foundation, Inc. +# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. # # # This configure script is free software; the Free Software Foundation @@ -650,6 +650,8 @@ LIBATOMIC DCFG_HAVE_LIBATOMIC DCFG_HAVE_64BIT_ATOMICS DCFG_HAVE_ATOMIC_BUILTINS +DRUNTIME_OS_MINFO_BRACKETING_FALSE +DRUNTIME_OS_MINFO_BRACKETING_TRUE DCFG_MINFO_BRACKETING DRUNTIME_OS_ARM_EABI_UNWINDER_FALSE DRUNTIME_OS_ARM_EABI_UNWINDER_TRUE @@ -801,7 +803,7 @@ PACKAGE_TARNAME PACKAGE_NAME PATH_SEPARATOR SHELL' -ac_subst_files='' +ac_subst_files='DRTSTUFF_SPEC' ac_user_opts=' enable_option_checking enable_multilib @@ -1568,7 +1570,7 @@ if $ac_init_version; then package-unused configure version-unused generated by GNU Autoconf 2.69 -Copyright (C) 2012-2019 Free Software Foundation, Inc. +Copyright (C) 2012 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF @@ -11496,7 +11498,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11499 "configure" +#line 11501 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -11602,7 +11604,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11605 "configure" +#line 11607 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -14119,6 +14121,14 @@ fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext + if test "$DCFG_MINFO_BRACKETING" = "true"; then + DRUNTIME_OS_MINFO_BRACKETING_TRUE= + DRUNTIME_OS_MINFO_BRACKETING_FALSE='#' +else + DRUNTIME_OS_MINFO_BRACKETING_TRUE='#' + DRUNTIME_OS_MINFO_BRACKETING_FALSE= +fi + ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' @@ -14856,6 +14866,14 @@ $as_echo "$version_specific_libs" >&6; } +# Add drtbegin.o/drtend.o to startfile/endfile specs in libgphobos.spec +if test "$DCFG_MINFO_BRACKETING" = "false"; then + DRTSTUFF_SPEC=$srcdir/src/drtstuff.spec +else + DRTSTUFF_SPEC=/dev/null +fi + + # Add dependencies for libgphobos.spec file SPEC_PHOBOS_DEPS="$LIBS" @@ -15095,6 +15113,10 @@ if test -z "${DRUNTIME_OS_ARM_EABI_UNWINDER_TRUE}" && test -z "${DRUNTIME_OS_ARM as_fn_error $? "conditional \"DRUNTIME_OS_ARM_EABI_UNWINDER\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi +if test -z "${DRUNTIME_OS_MINFO_BRACKETING_TRUE}" && test -z "${DRUNTIME_OS_MINFO_BRACKETING_FALSE}"; then + as_fn_error $? "conditional \"DRUNTIME_OS_MINFO_BRACKETING\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi if test -z "${DRUNTIME_ZLIB_SYSTEM_TRUE}" && test -z "${DRUNTIME_ZLIB_SYSTEM_FALSE}"; then as_fn_error $? "conditional \"DRUNTIME_ZLIB_SYSTEM\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 @@ -15566,7 +15588,7 @@ package-unused config.status version-unused configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" -Copyright (C) 2012-2019 Free Software Foundation, Inc. +Copyright (C) 2012 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." @@ -16099,7 +16121,24 @@ ac_tmp=$tmp # This happens for instance with `./config.status config.h'. if test -n "$CONFIG_FILES"; then - +if $AWK 'BEGIN { getline <"/dev/null" }' /dev/null; then + ac_cs_awk_getline=: + ac_cs_awk_pipe_init= + ac_cs_awk_read_file=' + while ((getline aline < (F[key])) > 0) + print(aline) + close(F[key])' + ac_cs_awk_pipe_fini= +else + ac_cs_awk_getline=false + ac_cs_awk_pipe_init="print \"cat <<'|#_!!_#|' &&\"" + ac_cs_awk_read_file=' + print "|#_!!_#|" + print "cat " F[key] " &&" + '$ac_cs_awk_pipe_init + # The final `:' finishes the AND list. + ac_cs_awk_pipe_fini='END { print "|#_!!_#|"; print ":" }' +fi ac_cr=`echo X | tr X '\015'` # On cygwin, bash can eat \r inside `` if the user requested igncr. # But we know of no other shell where ac_cr would be empty at this @@ -16117,6 +16156,17 @@ fi echo 'BEGIN {' >"$ac_tmp/subs1.awk" && _ACEOF +# Create commands to substitute file output variables. +{ + echo "cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1" && + echo 'cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK &&' && + echo "$ac_subst_files" | sed 's/.*/F["&"]="$&"/' && + echo "_ACAWK" && + echo "_ACEOF" +} >conf$$files.sh && +. ./conf$$files.sh || + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 +rm -f conf$$files.sh { echo "cat >conf$$subs.awk <<_ACEOF" && @@ -16193,7 +16243,7 @@ _ACAWK cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && for (key in S) S_is_set[key] = 1 FS = "" - + \$ac_cs_awk_pipe_init } { line = $ 0 @@ -16211,10 +16261,16 @@ cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && } else len += 1 + keylen } - + if (nfields == 3 && !substed) { + key = field[2] + if (F[key] != "" && line ~ /^[ ]*@.*@[ ]*$/) { + \$ac_cs_awk_read_file + next + } + } print line } - +\$ac_cs_awk_pipe_fini _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 @@ -16561,7 +16617,12 @@ s&@INSTALL@&$ac_INSTALL&;t t s&@MKDIR_P@&$ac_MKDIR_P&;t t $ac_datarootdir_hack " -eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ +eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | +if $ac_cs_awk_getline; then + $AWK -f "$ac_tmp/subs.awk" +else + $AWK -f "$ac_tmp/subs.awk" | $SHELL +fi \ >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && @@ -16674,7 +16735,8 @@ esac ;; # Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: # NOTE: Changes made to this file will be lost: look at ltmain.sh. # -# Copyright (C) 1996-2019 Free Software Foundation, Inc. +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, +# 2006, 2007, 2008, 2009 Free Software Foundation, Inc. # Written by Gordon Matzigkeit, 1996 # # This file is part of GNU Libtool. diff --git a/libphobos/configure.ac b/libphobos/configure.ac index 919bc194af4..3701a241b8e 100644 --- a/libphobos/configure.ac +++ b/libphobos/configure.ac @@ -143,6 +143,14 @@ DRUNTIME_LIBRARIES_DLOPEN DRUNTIME_LIBRARIES_ZLIB DRUNTIME_INSTALL_DIRECTORIES +# Add drtbegin.o/drtend.o to startfile/endfile specs in libgphobos.spec +if test "$DCFG_MINFO_BRACKETING" = "false"; then + DRTSTUFF_SPEC=$srcdir/src/drtstuff.spec +else + DRTSTUFF_SPEC=/dev/null +fi +AC_SUBST_FILE(DRTSTUFF_SPEC) + # Add dependencies for libgphobos.spec file SPEC_PHOBOS_DEPS="$LIBS" AC_SUBST(SPEC_PHOBOS_DEPS) diff --git a/libphobos/libdruntime/Makefile.am b/libphobos/libdruntime/Makefile.am index 8fa0ac104ef..eca6c4a56fd 100644 --- a/libphobos/libdruntime/Makefile.am +++ b/libphobos/libdruntime/Makefile.am @@ -74,6 +74,20 @@ endif if DRUNTIME_OS_SOLARIS ALL_DRUNTIME_COMPILE_DSOURCES += $(DRUNTIME_DSOURCES_SOLARIS) endif + +# Provide __start_minfo, __stop_minfo if linker doesn't. +if !DRUNTIME_OS_MINFO_BRACKETING + DRTSTUFF = gcc/drtbegin.o gcc/drtend.o + + toolexeclib_DATA = $(DRTSTUFF) + +gcc/drtbegin.o: gcc/drtstuff.c + $(COMPILE) -DDRT_BEGIN -c -o $@ $< + +gcc/drtend.o: gcc/drtstuff.c + $(COMPILE) -DDRT_END -c -o $@ $< +endif + # Generated by configure ALL_DRUNTIME_COMPILE_DSOURCES += $(DRUNTIME_DSOURCES_GENERATED) @@ -95,14 +109,16 @@ endif toolexeclib_LTLIBRARIES = libgdruntime.la libgdruntime_la_SOURCES = $(ALL_DRUNTIME_SOURCES) libgdruntime_la_LIBTOOLFLAGS = -libgdruntime_la_LDFLAGS = -Xcompiler -nophoboslib -version-info $(libtool_VERSION) +libgdruntime_la_LDFLAGS = -Wc,-nophoboslib,-dstartfiles,-B../src,-Bgcc \ + -version-info $(libtool_VERSION) libgdruntime_la_LIBADD = $(LIBATOMIC) $(LIBBACKTRACE) +libgdruntime_la_DEPENDENCIES = $(DRTSTUFF) # For static unittest, link objects directly unittest_static_SOURCES = ../testsuite/test_runner.d $(DRUNTIME_CSOURCES) \ $(DRUNTIME_SSOURCES) unittest_static_LIBTOOLFLAGS = -unittest_static_LDFLAGS = -Xcompiler -nophoboslib +unittest_static_LDFLAGS = -Wc,-nophoboslib unittest_static_LDADD = $(DRUNTIME_TEST_OBJECTS) $(LIBATOMIC) $(LIBBACKTRACE) EXTRA_unittest_static_DEPENDENCIES = $(DRUNTIME_TEST_OBJECTS) @@ -111,14 +127,14 @@ libgdruntime_t_la_SOURCES = $(DRUNTIME_CSOURCES) $(DRUNTIME_SSOURCES) libgdruntime_t_la_LIBTOOLFLAGS = # Automake by default does not generate shared libs for non-installed # libraries. Use -rpath to force shared lib generation. -libgdruntime_t_la_LDFLAGS = -Xcompiler -nophoboslib -rpath /foo -shared +libgdruntime_t_la_LDFLAGS = -Wc,-nophoboslib -rpath /foo -shared libgdruntime_t_la_LIBADD = $(DRUNTIME_TEST_LOBJECTS) $(LIBATOMIC) $(LIBBACKTRACE) EXTRA_libgdruntime_t_la_DEPENDENCIES = $(DRUNTIME_TEST_LOBJECTS) # For unittest unittest_SOURCES = ../testsuite/test_runner.d unittest_LIBTOOLFLAGS = -unittest_LDFLAGS = -Xcompiler -nophoboslib +unittest_LDFLAGS = -Wc,-nophoboslib unittest_LDADD = libgdruntime_t.la # Extra install and clean rules. diff --git a/libphobos/libdruntime/Makefile.in b/libphobos/libdruntime/Makefile.in index 89daa1c08ff..02331af95bd 100644 --- a/libphobos/libdruntime/Makefile.in +++ b/libphobos/libdruntime/Makefile.in @@ -31,6 +31,7 @@ # along with GCC; see the file COPYING3. If not see # . + VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ @@ -172,11 +173,10 @@ am__uninstall_files_from_dir = { \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } -am__installdirs = "$(DESTDIR)$(toolexeclibdir)" +am__installdirs = "$(DESTDIR)$(toolexeclibdir)" \ + "$(DESTDIR)$(toolexeclibdir)" LTLIBRARIES = $(toolexeclib_LTLIBRARIES) am__DEPENDENCIES_1 = -libgdruntime_la_DEPENDENCIES = $(am__DEPENDENCIES_1) \ - $(am__DEPENDENCIES_1) am__dirstamp = $(am__leading_dot)dirstamp am__objects_1 = core/atomic.lo core/attribute.lo core/bitop.lo \ core/checkedint.lo core/cpuid.lo core/demangle.lo \ @@ -1052,6 +1052,7 @@ am__can_run_installinfo = \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac +DATA = $(toolexeclib_DATA) am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is @@ -1278,6 +1279,7 @@ ALL_DRUNTIME_INSTALL_DSOURCES = $(DRUNTIME_DSOURCES) \ # Setup source files depending on configure + # Generated by configure ALL_DRUNTIME_COMPILE_DSOURCES = $(DRUNTIME_DSOURCES) $(am__append_1) \ $(am__append_2) $(am__append_3) $(am__append_4) \ @@ -1285,6 +1287,10 @@ ALL_DRUNTIME_COMPILE_DSOURCES = $(DRUNTIME_DSOURCES) $(am__append_1) \ $(am__append_8) $(am__append_9) $(am__append_10) \ $(am__append_11) $(am__append_12) \ $(DRUNTIME_DSOURCES_GENERATED) + +# Provide __start_minfo, __stop_minfo if linker doesn't. +@DRUNTIME_OS_MINFO_BRACKETING_FALSE@DRTSTUFF = gcc/drtbegin.o gcc/drtend.o +@DRUNTIME_OS_MINFO_BRACKETING_FALSE@toolexeclib_DATA = $(DRTSTUFF) ALL_DRUNTIME_SOURCES = $(ALL_DRUNTIME_COMPILE_DSOURCES) $(DRUNTIME_CSOURCES) \ $(DRUNTIME_SSOURCES) @@ -1294,15 +1300,18 @@ DRUNTIME_TEST_OBJECTS = $(ALL_DRUNTIME_COMPILE_DSOURCES:.d=.t.o) toolexeclib_LTLIBRARIES = libgdruntime.la libgdruntime_la_SOURCES = $(ALL_DRUNTIME_SOURCES) libgdruntime_la_LIBTOOLFLAGS = -libgdruntime_la_LDFLAGS = -Xcompiler -nophoboslib -version-info $(libtool_VERSION) +libgdruntime_la_LDFLAGS = -Wc,-nophoboslib,-dstartfiles,-B../src,-Bgcc \ + -version-info $(libtool_VERSION) + libgdruntime_la_LIBADD = $(LIBATOMIC) $(LIBBACKTRACE) +libgdruntime_la_DEPENDENCIES = $(DRTSTUFF) # For static unittest, link objects directly unittest_static_SOURCES = ../testsuite/test_runner.d $(DRUNTIME_CSOURCES) \ $(DRUNTIME_SSOURCES) unittest_static_LIBTOOLFLAGS = -unittest_static_LDFLAGS = -Xcompiler -nophoboslib +unittest_static_LDFLAGS = -Wc,-nophoboslib unittest_static_LDADD = $(DRUNTIME_TEST_OBJECTS) $(LIBATOMIC) $(LIBBACKTRACE) EXTRA_unittest_static_DEPENDENCIES = $(DRUNTIME_TEST_OBJECTS) @@ -1311,14 +1320,14 @@ libgdruntime_t_la_SOURCES = $(DRUNTIME_CSOURCES) $(DRUNTIME_SSOURCES) libgdruntime_t_la_LIBTOOLFLAGS = # Automake by default does not generate shared libs for non-installed # libraries. Use -rpath to force shared lib generation. -libgdruntime_t_la_LDFLAGS = -Xcompiler -nophoboslib -rpath /foo -shared +libgdruntime_t_la_LDFLAGS = -Wc,-nophoboslib -rpath /foo -shared libgdruntime_t_la_LIBADD = $(DRUNTIME_TEST_LOBJECTS) $(LIBATOMIC) $(LIBBACKTRACE) EXTRA_libgdruntime_t_la_DEPENDENCIES = $(DRUNTIME_TEST_LOBJECTS) # For unittest unittest_SOURCES = ../testsuite/test_runner.d unittest_LIBTOOLFLAGS = -unittest_LDFLAGS = -Xcompiler -nophoboslib +unittest_LDFLAGS = -Wc,-nophoboslib unittest_LDADD = libgdruntime_t.la DRUNTIME_DSOURCES_GENERATED = gcc/config.d gcc/libbacktrace.d # Source file definitions. Boring stuff, auto-generated with @@ -2454,6 +2463,27 @@ clean-libtool: -rm -rf rt/typeinfo/.libs rt/typeinfo/_libs -rm -rf rt/util/.libs rt/util/_libs -rm -rf rt/util/container/.libs rt/util/container/_libs +install-toolexeclibDATA: $(toolexeclib_DATA) + @$(NORMAL_INSTALL) + @list='$(toolexeclib_DATA)'; test -n "$(toolexeclibdir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(toolexeclibdir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(toolexeclibdir)" || exit 1; \ + fi; \ + for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + echo "$$d$$p"; \ + done | $(am__base_list) | \ + while read files; do \ + echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(toolexeclibdir)'"; \ + $(INSTALL_DATA) $$files "$(DESTDIR)$(toolexeclibdir)" || exit $$?; \ + done + +uninstall-toolexeclibDATA: + @$(NORMAL_UNINSTALL) + @list='$(toolexeclib_DATA)'; test -n "$(toolexeclibdir)" || list=; \ + files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ + dir='$(DESTDIR)$(toolexeclibdir)'; $(am__uninstall_files_from_dir) ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique @@ -2509,9 +2539,9 @@ distclean-tags: check-am: all-am $(MAKE) $(AM_MAKEFLAGS) $(check_LTLIBRARIES) $(check_PROGRAMS) check: check-am -all-am: Makefile $(LTLIBRARIES) +all-am: Makefile $(LTLIBRARIES) $(DATA) installdirs: - for dir in "$(DESTDIR)$(toolexeclibdir)"; do \ + for dir in "$(DESTDIR)$(toolexeclibdir)" "$(DESTDIR)$(toolexeclibdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am @@ -2614,7 +2644,8 @@ install-dvi: install-dvi-am install-dvi-am: -install-exec-am: install-toolexeclibLTLIBRARIES +install-exec-am: install-toolexeclibDATA \ + install-toolexeclibLTLIBRARIES install-html: install-html-am @@ -2653,7 +2684,8 @@ ps: ps-am ps-am: -uninstall-am: uninstall-toolexeclibLTLIBRARIES +uninstall-am: uninstall-toolexeclibDATA \ + uninstall-toolexeclibLTLIBRARIES .MAKE: check-am install-am install-strip @@ -2667,11 +2699,12 @@ uninstall-am: uninstall-toolexeclibLTLIBRARIES install-exec install-exec-am install-html install-html-am \ install-info install-info-am install-man install-pdf \ install-pdf-am install-ps install-ps-am install-strip \ - install-toolexeclibLTLIBRARIES installcheck installcheck-am \ - installdirs maintainer-clean maintainer-clean-generic \ - mostlyclean mostlyclean-compile mostlyclean-generic \ - mostlyclean-libtool pdf pdf-am ps ps-am tags tags-am uninstall \ - uninstall-am uninstall-toolexeclibLTLIBRARIES + install-toolexeclibDATA install-toolexeclibLTLIBRARIES \ + installcheck installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ + tags tags-am uninstall uninstall-am uninstall-toolexeclibDATA \ + uninstall-toolexeclibLTLIBRARIES .PRECIOUS: Makefile @@ -2695,6 +2728,12 @@ uninstall-am: uninstall-toolexeclibLTLIBRARIES %.t.o : %.t.lo @: +@DRUNTIME_OS_MINFO_BRACKETING_FALSE@gcc/drtbegin.o: gcc/drtstuff.c +@DRUNTIME_OS_MINFO_BRACKETING_FALSE@ $(COMPILE) -DDRT_BEGIN -c -o $@ $< + +@DRUNTIME_OS_MINFO_BRACKETING_FALSE@gcc/drtend.o: gcc/drtstuff.c +@DRUNTIME_OS_MINFO_BRACKETING_FALSE@ $(COMPILE) -DDRT_END -c -o $@ $< + # Extra install and clean rules. # This does not delete the .libs/.t.o files, but deleting # the .lo is good enough to rerun the rules diff --git a/libphobos/libdruntime/gcc/config.d.in b/libphobos/libdruntime/gcc/config.d.in index 3a1d493f3c4..1b5d5d9b692 100644 --- a/libphobos/libdruntime/gcc/config.d.in +++ b/libphobos/libdruntime/gcc/config.d.in @@ -35,9 +35,6 @@ enum ThreadModel enum ThreadModel GNU_Thread_Model = ThreadModel.@DCFG_THREAD_MODEL@; -// Whether the linker provides __start_minfo and __stop_minfo symbols -enum Minfo_Bracketing = @DCFG_MINFO_BRACKETING@; - // Whether target has support for builtin atomics. enum GNU_Have_Atomics = @DCFG_HAVE_ATOMIC_BUILTINS@; diff --git a/libphobos/libdruntime/gcc/drtstuff.c b/libphobos/libdruntime/gcc/drtstuff.c new file mode 100644 index 00000000000..40edda3bffb --- /dev/null +++ b/libphobos/libdruntime/gcc/drtstuff.c @@ -0,0 +1,39 @@ +/* Provide minfo section bracketing for D executables and shared libraries + when the linker doesn't provide it. + Copyright (C) 2019 Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 3, or (at your option) any later +version. + +GCC is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +Under Section 7 of GPL version 3, you are granted additional +permissions described in the GCC Runtime Library Exception, version +3.1, as published by the Free Software Foundation. + +You should have received a copy of the GNU General Public License and +a copy of the GCC Runtime Library Exception along with this program; +see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +. */ + +/* Avoid interference with targets without support for named sections. */ +#ifdef __ELF__ + +#ifdef DRT_BEGIN +void *__start_minfo[] +__attribute__((used, section("minfo"), aligned(sizeof(void *)))) = { }; +#endif + +#ifdef DRT_END +void *__stop_minfo[] +__attribute__((used, section("minfo"), aligned(sizeof(void *)))) = { }; +#endif + +#endif /* __ELF__ */ diff --git a/libphobos/libdruntime/rt/sections_elf_shared.d b/libphobos/libdruntime/rt/sections_elf_shared.d index 3f43bbd7663..d4e1ff07699 100644 --- a/libphobos/libdruntime/rt/sections_elf_shared.d +++ b/libphobos/libdruntime/rt/sections_elf_shared.d @@ -335,7 +335,6 @@ else /////////////////////////////////////////////////////////////////////////////// import gcc.config; -static assert(Minfo_Bracketing, "Can't use _d_dso_registry interface"); /* * This data structure is generated by the compiler, and then passed to diff --git a/libphobos/m4/druntime/os.m4 b/libphobos/m4/druntime/os.m4 index 0c711051bfb..92a2ba5cdf8 100644 --- a/libphobos/m4/druntime/os.m4 +++ b/libphobos/m4/druntime/os.m4 @@ -180,5 +180,6 @@ AC_DEFUN([DRUNTIME_OS_MINFO_BRACKETING], [AC_MSG_RESULT([no]) DCFG_MINFO_BRACKETING=false]) AC_SUBST(DCFG_MINFO_BRACKETING) + AM_CONDITIONAL([DRUNTIME_OS_MINFO_BRACKETING], [test "$DCFG_MINFO_BRACKETING" = "true"]) AC_LANG_POP([C]) ]) diff --git a/libphobos/src/Makefile.am b/libphobos/src/Makefile.am index 30896df1d94..51fd11e5c6c 100644 --- a/libphobos/src/Makefile.am +++ b/libphobos/src/Makefile.am @@ -57,14 +57,15 @@ toolexeclib_DATA = libgphobos.spec toolexeclib_LTLIBRARIES = libgphobos.la libgphobos_la_SOURCES = $(ALL_PHOBOS_SOURCES) $(ZLIB_SRC) libgphobos_la_LIBTOOLFLAGS = -libgphobos_la_LDFLAGS = -Xcompiler -nophoboslib -version-info $(libtool_VERSION) +libgphobos_la_LDFLAGS = -Wc,-nophoboslib,-dstartfiles,-B../libdruntime/gcc \ + -version-info $(libtool_VERSION) libgphobos_la_LIBADD = ../libdruntime/libgdruntime.la libgphobos_la_DEPENDENCIES = libgphobos.spec # For static unittest, link objects directly unittest_static_SOURCES = ../testsuite/test_runner.d $(ZLIB_SRC) unittest_static_LIBTOOLFLAGS = -unittest_static_LDFLAGS = -Xcompiler -nophoboslib -static-libtool-libs +unittest_static_LDFLAGS = -Wc,-nophoboslib -static-libtool-libs unittest_static_LDADD = $(PHOBOS_TEST_OBJECTS) \ ../libdruntime/libgdruntime.la EXTRA_unittest_static_DEPENDENCIES = $(PHOBOS_TEST_OBJECTS) @@ -72,7 +73,7 @@ EXTRA_unittest_static_DEPENDENCIES = $(PHOBOS_TEST_OBJECTS) # For unittest with dynamic library libgphobos_t_la_SOURCES = $(ZLIB_SRC) libgphobos_t_la_LIBTOOLFLAGS = -libgphobos_t_la_LDFLAGS = -Xcompiler -nophoboslib -rpath /foo -shared +libgphobos_t_la_LDFLAGS = -Wc,-nophoboslib -rpath /foo -shared libgphobos_t_la_LIBADD = $(PHOBOS_TEST_LOBJECTS) \ ../libdruntime/libgdruntime.la EXTRA_libgphobos_t_la_DEPENDENCIES = $(PHOBOS_TEST_LOBJECTS) @@ -80,7 +81,7 @@ EXTRA_libgphobos_t_la_DEPENDENCIES = $(PHOBOS_TEST_LOBJECTS) # For unittest unittest_SOURCES = ../testsuite/test_runner.d unittest_LIBTOOLFLAGS = -unittest_LDFLAGS = -Xcompiler -nophoboslib -shared +unittest_LDFLAGS = -Wc,-nophoboslib -shared unittest_LDADD = libgphobos_t.la ../libdruntime/libgdruntime.la # Extra install and clean rules. diff --git a/libphobos/src/Makefile.in b/libphobos/src/Makefile.in index a349fa7e897..3dffa6f6093 100644 --- a/libphobos/src/Makefile.in +++ b/libphobos/src/Makefile.in @@ -696,14 +696,16 @@ toolexeclib_DATA = libgphobos.spec toolexeclib_LTLIBRARIES = libgphobos.la libgphobos_la_SOURCES = $(ALL_PHOBOS_SOURCES) $(ZLIB_SRC) libgphobos_la_LIBTOOLFLAGS = -libgphobos_la_LDFLAGS = -Xcompiler -nophoboslib -version-info $(libtool_VERSION) +libgphobos_la_LDFLAGS = -Wc,-nophoboslib,-dstartfiles,-B../libdruntime/gcc \ + -version-info $(libtool_VERSION) + libgphobos_la_LIBADD = ../libdruntime/libgdruntime.la libgphobos_la_DEPENDENCIES = libgphobos.spec # For static unittest, link objects directly unittest_static_SOURCES = ../testsuite/test_runner.d $(ZLIB_SRC) unittest_static_LIBTOOLFLAGS = -unittest_static_LDFLAGS = -Xcompiler -nophoboslib -static-libtool-libs +unittest_static_LDFLAGS = -Wc,-nophoboslib -static-libtool-libs unittest_static_LDADD = $(PHOBOS_TEST_OBJECTS) \ ../libdruntime/libgdruntime.la @@ -712,7 +714,7 @@ EXTRA_unittest_static_DEPENDENCIES = $(PHOBOS_TEST_OBJECTS) # For unittest with dynamic library libgphobos_t_la_SOURCES = $(ZLIB_SRC) libgphobos_t_la_LIBTOOLFLAGS = -libgphobos_t_la_LDFLAGS = -Xcompiler -nophoboslib -rpath /foo -shared +libgphobos_t_la_LDFLAGS = -Wc,-nophoboslib -rpath /foo -shared libgphobos_t_la_LIBADD = $(PHOBOS_TEST_LOBJECTS) \ ../libdruntime/libgdruntime.la @@ -721,7 +723,7 @@ EXTRA_libgphobos_t_la_DEPENDENCIES = $(PHOBOS_TEST_LOBJECTS) # For unittest unittest_SOURCES = ../testsuite/test_runner.d unittest_LIBTOOLFLAGS = -unittest_LDFLAGS = -Xcompiler -nophoboslib -shared +unittest_LDFLAGS = -Wc,-nophoboslib -shared unittest_LDADD = libgphobos_t.la ../libdruntime/libgdruntime.la # Zlib sources when not using system libz diff --git a/libphobos/src/drtstuff.spec b/libphobos/src/drtstuff.spec new file mode 100644 index 00000000000..951a91b0e9c --- /dev/null +++ b/libphobos/src/drtstuff.spec @@ -0,0 +1,5 @@ +%rename startfile startfile_orig +*startfile: %(startfile_orig) drtbegin.o%s + +%rename endfile endfile_orig +*endfile: %(endfile_orig) drtend.o%s diff --git a/libphobos/src/libgphobos.spec.in b/libphobos/src/libgphobos.spec.in index 0a33e834b1a..ff9389696f3 100644 --- a/libphobos/src/libgphobos.spec.in +++ b/libphobos/src/libgphobos.spec.in @@ -4,5 +4,7 @@ # order. # +@DRTSTUFF_SPEC@ + %rename lib liborig_gdc_renamed -*lib: @SPEC_PHOBOS_DEPS@ %(liborig_gdc_renamed) +*lib: %{debuglib|defaultlib|nophoboslib: ; :@SPEC_PHOBOS_DEPS@} %(liborig_gdc_renamed) diff --git a/libphobos/testsuite/testsuite_flags.in b/libphobos/testsuite/testsuite_flags.in index 92cc436d29f..0326401e459 100755 --- a/libphobos/testsuite/testsuite_flags.in +++ b/libphobos/testsuite/testsuite_flags.in @@ -40,6 +40,7 @@ case ${query} in ;; --gdcldflags) GDCLDFLAGS="-B${BUILD_DIR}/src + -B${BUILD_DIR}/libdruntime/gcc -L${BUILD_DIR}/libdruntime/.libs -L${BUILD_DIR}/src/.libs" echo ${GDCLDFLAGS} -- 2.30.2