diff options
author | Iain Buclaw <ibuclaw@gdcproject.org> | 2021-03-26 15:46:24 +0100 |
---|---|---|
committer | Iain Buclaw <ibuclaw@gdcproject.org> | 2021-03-26 16:14:32 +0100 |
commit | fdfcb5353cc2b06fc80205cfcb3bc5ba25556264 (patch) | |
tree | 1ebb7f503eb0a4de98c3da2bdb0c41e76816843d /libphobos | |
parent | 8f5e18db259c8a9790feb1d73bb0348182264f15 (diff) | |
download | gcc-fdfcb5353cc2b06fc80205cfcb3bc5ba25556264.zip gcc-fdfcb5353cc2b06fc80205cfcb3bc5ba25556264.tar.gz gcc-fdfcb5353cc2b06fc80205cfcb3bc5ba25556264.tar.bz2 |
libphobos: Build all modules with -fversion=Shared when configured with --enable-shared
The libgdruntime_convenience library was built with `-fversion=Shared',
but the libphobos part wasn't when creating the static library.
As there are no issues compiling in Shared code into the static library,
to avoid mismatches the flag is now always present when --enable-shared
is turned on. Libtool's compiler PIC D flag is now the combination of
compiler PIC and D Shared flags, and AM_DFLAGS passes `-prefer-pic' to
libtool unless --enable-shared is turned off.
libphobos/ChangeLog:
* Makefile.in: Regenerate.
* configure: Regenerate.
* configure.ac: Substitute enable_shared, enable_static, and
phobos_lt_pic_flag.
* libdruntime/Makefile.am (AM_DFLAGS): Replace
phobos_compiler_pic_flag with phobos_lt_pic_flags, and
phobos_compiler_shared_flag.
* libdruntime/Makefile.in: Regenerate.
* src/Makefile.am (AM_DFLAGS): Replace phobos_compiler_pic_flag
with phobos_lt_pic_flag, and phobos_compiler_shared_flag.
* src/Makefile.in: Regenerate.
* testsuite/Makefile.in: Regenerate.
* testsuite/libphobos.druntime_shared/druntime_shared.exp: Remove
-fversion=Shared and -fno-moduleinfo from default extra test flags.
* testsuite/libphobos.phobos_shared/phobos_shared.exp: Likewise.
* testsuite/testsuite_flags.in: Add phobos_compiler_shared_flag to
--gdcflags.
Diffstat (limited to 'libphobos')
-rw-r--r-- | libphobos/Makefile.in | 3 | ||||
-rwxr-xr-x | libphobos/configure | 24 | ||||
-rw-r--r-- | libphobos/configure.ac | 17 | ||||
-rw-r--r-- | libphobos/libdruntime/Makefile.am | 2 | ||||
-rw-r--r-- | libphobos/libdruntime/Makefile.in | 5 | ||||
-rw-r--r-- | libphobos/src/Makefile.am | 2 | ||||
-rw-r--r-- | libphobos/src/Makefile.in | 5 | ||||
-rw-r--r-- | libphobos/testsuite/Makefile.in | 3 | ||||
-rw-r--r-- | libphobos/testsuite/libphobos.druntime_shared/druntime_shared.exp | 4 | ||||
-rw-r--r-- | libphobos/testsuite/libphobos.phobos_shared/phobos_shared.exp | 4 | ||||
-rwxr-xr-x | libphobos/testsuite/testsuite_flags.in | 3 |
11 files changed, 47 insertions, 25 deletions
diff --git a/libphobos/Makefile.in b/libphobos/Makefile.in index d422484..eab1268 100644 --- a/libphobos/Makefile.in +++ b/libphobos/Makefile.in @@ -298,6 +298,8 @@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ +enable_shared = @enable_shared@ +enable_static = @enable_static@ exec_prefix = @exec_prefix@ gcc_version = @gcc_version@ gdc_include_dir = @gdc_include_dir@ @@ -327,6 +329,7 @@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ phobos_compiler_pic_flag = @phobos_compiler_pic_flag@ phobos_compiler_shared_flag = @phobos_compiler_shared_flag@ +phobos_lt_pic_flag = @phobos_lt_pic_flag@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ diff --git a/libphobos/configure b/libphobos/configure index c940a40..59ca64a 100755 --- a/libphobos/configure +++ b/libphobos/configure @@ -705,6 +705,9 @@ libphobos_builddir get_gcc_base_ver phobos_compiler_shared_flag phobos_compiler_pic_flag +phobos_lt_pic_flag +enable_static +enable_shared OTOOL64 OTOOL LIPO @@ -11746,7 +11749,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11749 "configure" +#line 11752 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -11852,7 +11855,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11855 "configure" +#line 11858 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -13997,8 +14000,14 @@ CFLAGS=$lt_save_CFLAGS GDCFLAGS=$gdc_save_DFLAGS + + # libtool variables for Phobos shared and position-independent compiles. # +# Use phobos_lt_pic_flag to designate the automake variable +# used to encapsulate the default libtool approach to creating objects +# with position-independent code. Default: -prefer-pic. +# # Use phobos_compiler_shared_flag to designate the compile-time flags for # creating shared objects. Default: -fversion=Shared. # @@ -14010,26 +14019,23 @@ CFLAGS=$lt_save_CFLAGS # libtool, and so we make it here. How it is handled is that in shared # compilations the `lt_prog_compiler_pic_D' variable is used to instead # ensure that conditional compilation of shared runtime code is compiled in. -# The original PIC flags are then used in the compilation of every object. -# -# Why are objects destined for libgphobos.a compiled with -fPIC? -# Because -fPIC is not harmful to use for objects destined for static -# libraries. In addition, using -fPIC will allow the use of static -# libgphobos.a in the creation of other D shared libraries. if test "$enable_shared" = yes; then + phobos_lt_pic_flag="-prefer-pic" phobos_compiler_pic_flag="$lt_prog_compiler_pic_D" phobos_compiler_shared_flag="-fversion=Shared" else + phobos_lt_pic_flag= phobos_compiler_pic_flag= phobos_compiler_shared_flag= fi + # Override the libtool's pic_flag and pic_mode. # Do this step after AM_PROG_LIBTOOL, but before AC_OUTPUT. # NB: this impacts --with-pic and --without-pic. -lt_prog_compiler_pic_D="$phobos_compiler_shared_flag" +lt_prog_compiler_pic_D="$phobos_compiler_pic_flag $phobos_compiler_shared_flag" pic_mode='default' # Determine what GCC version number to use in filesystem paths. diff --git a/libphobos/configure.ac b/libphobos/configure.ac index cc9af29..248d0eb 100644 --- a/libphobos/configure.ac +++ b/libphobos/configure.ac @@ -91,9 +91,15 @@ AC_SUBST(CFLAGS_FOR_BUILD) LT_INIT(dlopen) AM_PROG_LIBTOOL WITH_LOCAL_DRUNTIME([LT_LANG([D])], []) +AC_SUBST(enable_shared) +AC_SUBST(enable_static) # libtool variables for Phobos shared and position-independent compiles. # +# Use phobos_lt_pic_flag to designate the automake variable +# used to encapsulate the default libtool approach to creating objects +# with position-independent code. Default: -prefer-pic. +# # Use phobos_compiler_shared_flag to designate the compile-time flags for # creating shared objects. Default: -fversion=Shared. # @@ -105,26 +111,23 @@ WITH_LOCAL_DRUNTIME([LT_LANG([D])], []) # libtool, and so we make it here. How it is handled is that in shared # compilations the `lt_prog_compiler_pic_D' variable is used to instead # ensure that conditional compilation of shared runtime code is compiled in. -# The original PIC flags are then used in the compilation of every object. -# -# Why are objects destined for libgphobos.a compiled with -fPIC? -# Because -fPIC is not harmful to use for objects destined for static -# libraries. In addition, using -fPIC will allow the use of static -# libgphobos.a in the creation of other D shared libraries. if test "$enable_shared" = yes; then + phobos_lt_pic_flag="-prefer-pic" phobos_compiler_pic_flag="$lt_prog_compiler_pic_D" phobos_compiler_shared_flag="-fversion=Shared" else + phobos_lt_pic_flag= phobos_compiler_pic_flag= phobos_compiler_shared_flag= fi +AC_SUBST(phobos_lt_pic_flag) AC_SUBST(phobos_compiler_pic_flag) AC_SUBST(phobos_compiler_shared_flag) # Override the libtool's pic_flag and pic_mode. # Do this step after AM_PROG_LIBTOOL, but before AC_OUTPUT. # NB: this impacts --with-pic and --without-pic. -lt_prog_compiler_pic_D="$phobos_compiler_shared_flag" +lt_prog_compiler_pic_D="$phobos_compiler_pic_flag $phobos_compiler_shared_flag" pic_mode='default' # Determine what GCC version number to use in filesystem paths. diff --git a/libphobos/libdruntime/Makefile.am b/libphobos/libdruntime/Makefile.am index 945271e..535ca26 100644 --- a/libphobos/libdruntime/Makefile.am +++ b/libphobos/libdruntime/Makefile.am @@ -23,7 +23,7 @@ D_EXTRA_DFLAGS=-nostdinc -I $(srcdir) -I . # D flags for compilation AM_DFLAGS= \ - $(phobos_compiler_pic_flag) \ + $(phobos_lt_pic_flag) $(phobos_compiler_shared_flag) \ $(WARN_DFLAGS) $(CHECKING_DFLAGS) $(CET_DFLAGS) # Flags for other kinds of sources diff --git a/libphobos/libdruntime/Makefile.in b/libphobos/libdruntime/Makefile.in index 06c0296..7960add 100644 --- a/libphobos/libdruntime/Makefile.in +++ b/libphobos/libdruntime/Makefile.in @@ -659,6 +659,8 @@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ +enable_shared = @enable_shared@ +enable_static = @enable_static@ exec_prefix = @exec_prefix@ gcc_version = @gcc_version@ gdc_include_dir = @gdc_include_dir@ @@ -688,6 +690,7 @@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ phobos_compiler_pic_flag = @phobos_compiler_pic_flag@ phobos_compiler_shared_flag = @phobos_compiler_shared_flag@ +phobos_lt_pic_flag = @phobos_lt_pic_flag@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ @@ -720,7 +723,7 @@ D_EXTRA_DFLAGS = -nostdinc -I $(srcdir) -I . # D flags for compilation AM_DFLAGS = \ - $(phobos_compiler_pic_flag) \ + $(phobos_lt_pic_flag) $(phobos_compiler_shared_flag) \ $(WARN_DFLAGS) $(CHECKING_DFLAGS) $(CET_DFLAGS) diff --git a/libphobos/src/Makefile.am b/libphobos/src/Makefile.am index 2de8ab9..0dc2a26 100644 --- a/libphobos/src/Makefile.am +++ b/libphobos/src/Makefile.am @@ -24,7 +24,7 @@ D_EXTRA_DFLAGS=-nostdinc -I $(srcdir) \ # D flags for compilation AM_DFLAGS= \ - $(phobos_compiler_pic_flag) \ + $(phobos_lt_pic_flag) $(phobos_compiler_shared_flag) \ $(WARN_DFLAGS) $(CHECKING_DFLAGS) $(CET_DFLAGS) # Flags for other kinds of sources diff --git a/libphobos/src/Makefile.in b/libphobos/src/Makefile.in index 2e72178..3345351 100644 --- a/libphobos/src/Makefile.in +++ b/libphobos/src/Makefile.in @@ -414,6 +414,8 @@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ +enable_shared = @enable_shared@ +enable_static = @enable_static@ exec_prefix = @exec_prefix@ gcc_version = @gcc_version@ gdc_include_dir = @gdc_include_dir@ @@ -443,6 +445,7 @@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ phobos_compiler_pic_flag = @phobos_compiler_pic_flag@ phobos_compiler_shared_flag = @phobos_compiler_shared_flag@ +phobos_lt_pic_flag = @phobos_lt_pic_flag@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ @@ -477,7 +480,7 @@ D_EXTRA_DFLAGS = -nostdinc -I $(srcdir) \ # D flags for compilation AM_DFLAGS = \ - $(phobos_compiler_pic_flag) \ + $(phobos_lt_pic_flag) $(phobos_compiler_shared_flag) \ $(WARN_DFLAGS) $(CHECKING_DFLAGS) $(CET_DFLAGS) diff --git a/libphobos/testsuite/Makefile.in b/libphobos/testsuite/Makefile.in index c38a468..51eb4ef 100644 --- a/libphobos/testsuite/Makefile.in +++ b/libphobos/testsuite/Makefile.in @@ -242,6 +242,8 @@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ +enable_shared = @enable_shared@ +enable_static = @enable_static@ exec_prefix = @exec_prefix@ gcc_version = @gcc_version@ gdc_include_dir = @gdc_include_dir@ @@ -271,6 +273,7 @@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ phobos_compiler_pic_flag = @phobos_compiler_pic_flag@ phobos_compiler_shared_flag = @phobos_compiler_shared_flag@ +phobos_lt_pic_flag = @phobos_lt_pic_flag@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ diff --git a/libphobos/testsuite/libphobos.druntime_shared/druntime_shared.exp b/libphobos/testsuite/libphobos.druntime_shared/druntime_shared.exp index 6ca62a3..2b25613 100644 --- a/libphobos/testsuite/libphobos.druntime_shared/druntime_shared.exp +++ b/libphobos/testsuite/libphobos.druntime_shared/druntime_shared.exp @@ -34,8 +34,8 @@ dg-init # Main loop. foreach test $tests { set libphobos_test_name "$subdir/[dg-trim-dirname $srcdir/../libdruntime $test]" - dg-runtest $test "-fversion=Shared -shared-libphobos" \ - "-fmain -fbuilding-libphobos-tests -fno-moduleinfo $version_flags" + dg-runtest $test "-shared-libphobos" \ + "-fmain -fbuilding-libphobos-tests $version_flags" set libphobos_test_name "" } diff --git a/libphobos/testsuite/libphobos.phobos_shared/phobos_shared.exp b/libphobos/testsuite/libphobos.phobos_shared/phobos_shared.exp index da31304..3a847e7 100644 --- a/libphobos/testsuite/libphobos.phobos_shared/phobos_shared.exp +++ b/libphobos/testsuite/libphobos.phobos_shared/phobos_shared.exp @@ -45,8 +45,8 @@ dg-init # Main loop. foreach test $tests { set libphobos_test_name "$subdir/[dg-trim-dirname $srcdir/../src $test]" - dg-runtest $test "-fversion=Shared -shared-libphobos" \ - "-fmain -fbuilding-libphobos-tests -fno-moduleinfo $version_flags" + dg-runtest $test "-shared-libphobos" \ + "-fmain -fbuilding-libphobos-tests $version_flags" set libphobos_test_name "" } diff --git a/libphobos/testsuite/testsuite_flags.in b/libphobos/testsuite/testsuite_flags.in index 6a2d79f..bafd5ad4 100755 --- a/libphobos/testsuite/testsuite_flags.in +++ b/libphobos/testsuite/testsuite_flags.in @@ -28,7 +28,8 @@ case ${query} in ;; --gdcflags) GDCFLAGS_default="-fmessage-length=0 -fno-show-column" - GDCFLAGS_config="@WARN_DFLAGS@ @GDCFLAGS@ @CET_DFLAGS@ -fno-release -funittest" + GDCFLAGS_config="@WARN_DFLAGS@ @GDCFLAGS@ @CET_DFLAGS@ + @phobos_compiler_shared_flag@ -fno-release -funittest" echo ${GDCFLAGS_default} ${GDCFLAGS_config} ;; --gdcpaths) |