From 11ae3c5fe78154e4934d0c8c1eb744c9104427b2 Mon Sep 17 00:00:00 2001 From: Oliver Tappe Date: Fri, 1 Aug 2014 14:53:45 +0200 Subject: [PATCH] Cleanup build system and configuration. * Drop unused variables from build system that refer to the system libraries. * Drop unused lists of libgcc objects. * Drop no longer used variables from configuration script. * Remove no longer needed building of kernel-libgcc and -libsupc++ from build_cross_tools_gcc4, only the boot-specific (32-bit) libs are built for a x86_64 target. * Explicitly disable threads and TLS support when building the cross compiler, as the only libraries that are used by Haiku's build system is the 32-bit libgcc and libsupc++ for the bootloader on x86_64 (and for that neither is wanted). --- build/jam/ArchitectureRules | 59 ++------------ build/jam/BuildSetup | 23 +----- build/scripts/build_cross_tools_gcc4 | 53 +++---------- configure | 110 +-------------------------- 4 files changed, 23 insertions(+), 222 deletions(-) diff --git a/build/jam/ArchitectureRules b/build/jam/ArchitectureRules index d18159b958..b7b68d6389 100644 --- a/build/jam/ArchitectureRules +++ b/build/jam/ArchitectureRules @@ -59,7 +59,6 @@ rule ArchitectureSetup architecture HAIKU_LINK_$(architecture) = $(HAIKU_CC_$(architecture)) ; HAIKU_LINKFLAGS_$(architecture) = $(gccBaseFlags) ; - HAIKU_HDRS_$(architecture) = [ FStandardHeaders $(architecture) ] ; HAIKU_CCFLAGS_$(architecture) += $(gccBaseFlags) -nostdinc ; HAIKU_C++FLAGS_$(architecture) += $(gccBaseFlags) -nostdinc ; @@ -155,48 +154,6 @@ rule ArchitectureSetup architecture HAIKU_PRIVATE_SYSTEM_HEADERS_$(architecture) = [ PrivateHeaders $(DOT) system system/arch/$(cpu) ] ; - # Add some grist to the libgcc objects - HAIKU_GCC_LIBGCC_OBJECTS_$(architecture) - = $(HAIKU_GCC_LIBGCC_OBJECTS_$(architecture):G=libgcc!$(architecture)) ; - - # List of libgcc objects we don't want to keep - HAIKU_GCC_LIBGCC_OBJECTS_EXCLUDES_$(architecture) - = eabi.o ; - - # the C++ standard library - HAIKU_BUILD_SHARED_LIBSTDC++_$(architecture) = ; - if $(HAIKU_SHARED_LIBSTDC++_$(architecture)) { - HAIKU_LIBSTDC++_$(architecture) - = $(HAIKU_SHARED_LIBSTDC++_$(architecture)) ; - } else { - # no shared library available with the compiler -- build it - if $(gccVersion[1]) = 2 { - HAIKU_LIBSTDC++_$(architecture) = libstdc++.r4.so ; - } else { - HAIKU_LIBSTDC++_$(architecture) = <$(architecture)>libstdc++.so ; - } - HAIKU_SHARED_LIBSTDC++_$(architecture) - = $(HAIKU_LIBSTDC++_$(architecture)) ; - HAIKU_BUILD_SHARED_LIBSTDC++_$(architecture) = 1 ; - } - - # the C++ support (runtime) library - HAIKU_BUILD_SHARED_LIBSUPC++_$(architecture) = ; - if $(HAIKU_SHARED_LIBSUPC++_$(architecture)) { - HAIKU_LIBSUPC++_$(architecture) - = $(HAIKU_SHARED_LIBSUPC++_$(architecture)) ; - } else { - # no shared library available with the compiler -- build it for gcc 4 - if $(gccVersion[1]) != 2 { - HAIKU_SHARED_LIBSUPC++_$(architecture) - = <$(architecture)>libsupc++.so ; - HAIKU_BUILD_SHARED_LIBSUPC++_$(architecture) = 1 ; - } - - HAIKU_LIBSUPC++_$(architecture) - = $(HAIKU_SHARED_LIBSUPC++_$(architecture)) ; - } - # library and executable glue code local commonGlueCode = init_term_dyn.o @@ -237,10 +194,6 @@ rule ArchitectureSetup architecture HAIKU_LIBRARY_NAME_MAP_$(architecture)_$(i) = $(library:G=$(libraryGrist)) ; } - HAIKU_LIBRARY_NAME_MAP_$(architecture)_libstdc++ - = $(HAIKU_LIBSTDC++_$(architecture)) ; - HAIKU_LIBRARY_NAME_MAP_$(architecture)_libsupc++ - = $(HAIKU_LIBSUPC++_$(architecture)) ; HAIKU_LIBRARY_NAME_MAP_$(architecture)_localestub = <$(architecture)>liblocalestub.a ; if $(architecture) = $(HAIKU_PACKAGING_ARCHS[1]) { @@ -752,11 +705,11 @@ rule MultiArchSubDirSetup architectures # packaging architectures, if is empty) an object is # prepared that can be used for an "on ... { ... }" block to set up subdir # variables for the respective packaging architecture. Most notably - # TARGET_PACKAGING_ARCH, TARGET_ARCH, TARGET_LIBSUPC++, and TARGET_LIBSTDC++ - # are set to the values for the respective packaging architecture. The - # per-subdir variables SOURCE_GRIST, LOCATE_TARGET, LOCATE_SOURCE, - # SEARCH_SOURCE, *_LOCATE_TARGET, are reset. All SUBDIR* and config - # variables are set to the values they had when this rule was invoked. + # TARGET_PACKAGING_ARCH, TARGET_ARCH are set to the values for the + # respective packaging architecture. The per-subdir variables SOURCE_GRIST, + # LOCATE_TARGET, LOCATE_SOURCE, SEARCH_SOURCE, *_LOCATE_TARGET, are reset. + # All SUBDIR* and config variables are set to the values they had when this + # rule was invoked. local result ; architectures ?= $(TARGET_PACKAGING_ARCHS) ; @@ -774,7 +727,7 @@ rule MultiArchSubDirSetup architectures TARGET_PACKAGING_ARCH on $(architectureObject) = $(architecture) ; local var ; - for var in TARGET_ARCH TARGET_LIBSUPC++ TARGET_LIBSTDC++ { + for var in TARGET_ARCH { $(var) on $(architectureObject) = $($(var)_$(architecture)) ; } diff --git a/build/jam/BuildSetup b/build/jam/BuildSetup index 3f82f42fe6..c59049d428 100644 --- a/build/jam/BuildSetup +++ b/build/jam/BuildSetup @@ -132,9 +132,6 @@ if $(HAIKU_PACKAGING_ARCH) { # define primary packaging architecture macro HAIKU_DEFINES = __HAIKU_PRIMARY_PACKAGING_ARCH=\\\"$(HAIKU_PACKAGING_ARCH)\\\" ; -HAIKU_LIBSUPC++ = $(HAIKU_LIBSUPC++_$(HAIKU_PACKAGING_ARCH)) ; -HAIKU_LIBSTDC++ = $(HAIKU_LIBSTDC++_$(HAIKU_PACKAGING_ARCH)) ; - # distro compatibility level defines HAIKU_DISTRO_COMPATIBILITY ?= "default" ; @@ -655,8 +652,6 @@ local buildVars = PRIVATE_KERNEL_HEADERS - LIBSTDC++ LIBSUPC++ - NETWORK_LIBS NETAPI_LIB SELECT_UNAME_ETC_LIB EXECUTABLE_MIME_TYPE @@ -680,8 +675,6 @@ local archDependentBuildVars = PRIVATE_SYSTEM_HEADERS - LIBSTDC++ LIBSUPC++ - ARCH_OBJECT_DIR COMMON_DEBUG_OBJECT_DIR DEBUG_$(HAIKU_DEBUG_LEVELS)_OBJECT_DIR ; @@ -696,17 +689,11 @@ if $(TARGET_PLATFORM) = haiku { TARGET_$(var) = $(HAIKU_$(var)) ; } - TARGET_KERNEL_LIBGCC - = $(HAIKU_KERNEL_LIBGCC_$(TARGET_PACKAGING_ARCH)) ; - TARGET_KERNEL_LIBSUPC++ - = $(HAIKU_KERNEL_LIBSUPC++_$(TARGET_PACKAGING_ARCH)) ; - TARGET_BOOT_LIBGCC - = $(HAIKU_BOOT_LIBGCC_$(TARGET_PACKAGING_ARCH)) ; - TARGET_BOOT_LIBSUPC++ - = $(HAIKU_BOOT_LIBSUPC++_$(TARGET_PACKAGING_ARCH)) ; + TARGET_BOOT_LIBGCC = $(HAIKU_BOOT_LIBGCC_$(TARGET_PACKAGING_ARCH)) ; + TARGET_BOOT_LIBSUPC++ = $(HAIKU_BOOT_LIBSUPC++_$(TARGET_PACKAGING_ARCH)) ; - TARGET_BOOT_PLATFORM ?= $(HAIKU_BOOT_PLATFORM) ; - TARGET_BOOT_BOARD ?= $(HAIKU_BOOT_BOARD) ; + TARGET_BOOT_PLATFORM ?= $(HAIKU_BOOT_PLATFORM) ; + TARGET_BOOT_BOARD ?= $(HAIKU_BOOT_BOARD) ; local architecture ; for architecture in $(TARGET_PACKAGING_ARCHS) { @@ -724,8 +711,6 @@ if $(TARGET_PLATFORM) = haiku { TARGET_$(var)_$(TARGET_PACKAGING_ARCH) = $(HOST_$(var)) ; } - TARGET_KERNEL_LIBGCC = ; - TARGET_KERNEL_LIBSUPC++ = ; TARGET_BOOT_LIBGCC = ; TARGET_BOOT_LIBSUPC++ = ; diff --git a/build/scripts/build_cross_tools_gcc4 b/build/scripts/build_cross_tools_gcc4 index 75f424b9e9..0b20a83927 100755 --- a/build/scripts/build_cross_tools_gcc4 +++ b/build/scripts/build_cross_tools_gcc4 @@ -16,7 +16,6 @@ installDir=$4 shift 4 additionalMakeArgs=$* -kernelCcFlags="-D_KERNEL_MODE" ccFlags="-O2" cxxFlags="-O2" case $haikuMachine in @@ -25,7 +24,6 @@ x86_64-*) # explicitly using --enable-multilib that causes a build # failure binutilsConfigureArgs="" - kernelCcFlags="$kernelCcFlags -mno-red-zone" ;; m68k-*) binutilsConfigureArgs="--enable-multilib" @@ -212,7 +210,7 @@ CFLAGS="$ccFlags" CXXFLAGS="$cxxFlags" "$gccSourceDir/configure" \ --prefix="$installDir" $buildHostSpec --target=$haikuMachine \ --disable-nls --disable-shared --with-system-zlib \ --enable-languages=c,c++ --enable-lto --enable-frame-pointer \ - --with-sysroot="$sysrootDir" --enable-threads=posix --enable-tls \ + --with-sysroot="$sysrootDir" --disable-threads --disable-tls \ $gccConfigureArgs \ || exit 1 @@ -228,46 +226,15 @@ $MAKE $additionalMakeArgs install || { exit 1 } -# build libraries for the kernel if the target arch requires it -if [ -n "$kernelCcFlags" ]; then - # switch threads config to single for libgcc - ln -sf "$gccSourceDir/libgcc/gthr-single.h" "$haikuMachine/libgcc/gthr-default.h" - $MAKE -C "$haikuMachine/libgcc" clean - $MAKE -C "$haikuMachine/libgcc" CFLAGS="-g -O2 $kernelCcFlags" || { - echo "Error: Building kernel libgcc failed." >&2 - exit 1 - } - - cp "$haikuMachine/libgcc/libgcc.a" \ - "$installDir/$haikuMachine/lib/libgcc-kernel.a" || exit 1 - - $MAKE -C "$haikuMachine/libstdc++-v3/libsupc++" clean - - # switch threads config to single for libsupc++ - [ -f "$haikuMachine/32/libstdc++-v3/include/$haikuMachine/bits/gthr-default.h" ] \ - && cp -f "$haikuMachine/32/libstdc++-v3/include/$haikuMachine/bits/gthr-single.h" \ - "$haikuMachine/32/libstdc++-v3/include/$haikuMachine/bits/gthr-default.h" - cp -f "$haikuMachine/libstdc++-v3/include/$haikuMachine/bits/gthr-single.h" \ - "$haikuMachine/libstdc++-v3/include/$haikuMachine/bits/gthr-default.h" - [ -f "$haikuMachine/32/libstdc++-v3/config.h" ] \ - && sed -i '/.*_GLIBCXX_HAS_GTHREADS.*/c\#undef _GLIBCXX_HAS_GTHREADS' \ - "$haikuMachine/32/libstdc++-v3/config.h" - [ -f "$haikuMachine/32/libstdc++-v3/include/$haikuMachine/bits/c++config.h" ] \ - && sed -i '/.*_GLIBCXX_HAS_TLS.*/c\#undef _GLIBCXX_HAS_TLS' \ - "$haikuMachine/32/libstdc++-v3/include/$haikuMachine/bits/c++config.h" - sed -i '/.*_GLIBCXX_HAS_GTHREADS.*/c\#undef _GLIBCXX_HAS_GTHREADS' \ - "$haikuMachine/libstdc++-v3/config.h" - sed -i '/.*_GLIBCXX_HAVE_TLS.*/c\#undef _GLIBCXX_HAVE_TLS' \ - "$haikuMachine/libstdc++-v3/include/$haikuMachine/bits/c++config.h" - $MAKE -C "$haikuMachine/libstdc++-v3/libsupc++" CFLAGS="-g -O2 $kernelCcFlags" \ - CXXFLAGS="-g -O2 $kernelCcFlags" || { - echo "Error: Building kernel libsupc++ failed." >&2 - exit 1 - } - - cp "$haikuMachine/libstdc++-v3/libsupc++/.libs/libsupc++.a" \ - "$installDir/$haikuMachine/lib/libsupc++-kernel.a" || exit 1 -fi +case $haikuMachine in +x86_64-*) + # pick up the 32-bit libraries for the bootloader + bootLibgcc=`$installDir/bin/$haikuMachine-gcc -m32 -print-file-name=libgcc.a` + $installDir/bin/$haikuMachine-strip --strip-debug $bootLibgcc + bootLibsupcxx=`$installDir/bin/$haikuMachine-gcc -m32 -print-file-name=libsupc++.a` + $installDir/bin/$haikuMachine-strip --strip-debug $bootLibsupcxx + ;; +esac # cleanup diff --git a/configure b/configure index 14dd49c1b0..f92029d00d 100755 --- a/configure +++ b/configure @@ -248,8 +248,6 @@ standard_gcc_settings() local gccRawVersion=`$gcc -dumpversion` local gccMachine=`$gcc -dumpmachine` - local libgcc=${gccdir}/libgcc.a - # determine architecture from machine triple case $gccMachine in arm-*) targetCpu=arm;; @@ -264,75 +262,8 @@ standard_gcc_settings() esac local targetArch=$targetCpu - local staticLibStdCxx - local sharedLibStdCxx - local staticLibSupCxx - local sharedLibSupCxx - local kernelLibgcc - local cxxHeaders case $gccRawVersion in - 4.*) - # for gcc 4 we use the libstdc++ and libsupc++ that come with the - # compiler - staticLibStdCxx=`$gcc -print-file-name=libstdc++.a` - sharedLibStdCxx=`$gcc -print-file-name=libstdc++.so` - staticLibSupCxx=`$gcc -print-file-name=libsupc++.a` - sharedLibSupCxx=`$gcc -print-file-name=libsupc++.so` - - # If the architecture has separate runtime libraries for the - # kernel, use them. - kernelLibgcc=`$gcc -print-file-name=libgcc-kernel.a` - if [ $kernelLibgcc = libgcc-kernel.a ]; then - kernelLibgcc=$libgcc - fi - kernelLibSupCxx=`$gcc -print-file-name=libsupc++-kernel.a` - if [ $kernelLibSupCxx = libsupc++-kernel.a ]; then - kernelLibSupCxx=$staticLibSupCxx - fi - - local headersBase=$gccdir/../../../.. - local headers=$headersBase/$gccMachine/include/c++/$gccRawVersion - if [ ! -d $headers ]; then - headers=$headersBase/include/c++/$gccRawVersion - fi - - cxxHeaders=$headers - for d in $gccMachine backward ext; do - # Note: We need the line break, otherwise the line might become - # too long for jam (512 bytes max). - cxxHeaders="$cxxHeaders $headers/$d" - done - - # Unset the HAIKU_{SHARED,STATIC}_LIB{STD,SUP}CXX variables, if the - # compiler didn't give us actual file names. Otherwise resolve - # symlinks to avoid problems when copying the libraries to the - # image. - - if [ $staticLibStdCxx = libstdc++.a ]; then - staticLibStdCxx= - else - staticLibStdCxx=`$readlink $staticLibStdCxx` - fi - - if [ $sharedLibStdCxx = libstdc++.so ]; then - sharedLibStdCxx= - else - sharedLibStdCxx=`$readlink $sharedLibStdCxx` - fi - - if [ $staticLibSupCxx = libsupc++.a ]; then - staticLibSupCxx= - else - staticLibSupCxx=`$readlink $staticLibSupCxx` - fi - - if [ $sharedLibSupCxx = libsupc++.so ]; then - sharedLibSupCxx= - else - sharedLibSupCxx=`$readlink $sharedLibSupCxx` - fi - ;; 2.9*) # check for correct (most up-to-date) legacy compiler and complain # if an older one is installed @@ -342,8 +273,6 @@ standard_gcc_settings() exit 1; fi - kernelLibgcc=$libgcc - kernelLibSupCxx= targetArch=x86_gcc2 ;; esac @@ -354,7 +283,7 @@ standard_gcc_settings() case $gccMachine in x86_64-*) # Boot loader is 32-bit, need the 32-bit libs and c++ config - bootLibgcc=`$gcc -m32 -print-libgcc-file-name` + bootLibgcc=`$gcc -m32 -print-file-name=libgcc.a` bootLibSupCxx=`$gcc -m32 -print-file-name=libsupc++.a` local headersBase=$gccdir/../../../.. @@ -364,10 +293,6 @@ standard_gcc_settings() fi bootCxxHeaders="$headers/$gccMachine/32" ;; - *) - bootLibgcc=$libgcc - bootLibSupCxx=$staticLibSupCxx - ;; esac # determine whether graphite loop optimization should/can be used @@ -400,19 +325,9 @@ standard_gcc_settings() set_variable HAIKU_GCC_RAW_VERSION_$targetArch $gccRawVersion set_variable HAIKU_GCC_MACHINE_$targetArch $gccMachine set_variable HAIKU_GCC_LIB_DIR_$targetArch $gccdir - set_variable HAIKU_GCC_LIBGCC_$targetArch $libgcc - set_variable HAIKU_GCC_HEADERS_DIR_$targetArch \ - "${gccdir}/include ${gccdir}/include-fixed" - set_variable HAIKU_STATIC_LIBSTDCXX_$targetArch "$staticLibStdCxx" - set_variable HAIKU_SHARED_LIBSTDCXX_$targetArch "$sharedLibStdCxx" - set_variable HAIKU_STATIC_LIBSUPCXX_$targetArch "$staticLibSupCxx" - set_variable HAIKU_SHARED_LIBSUPCXX_$targetArch "$sharedLibSupCxx" - set_variable HAIKU_KERNEL_LIBSUPCXX_$targetArch "$kernelLibSupCxx" - set_variable HAIKU_BOOT_LIBSUPCXX_$targetArch "$bootLibSupCxx" - set_variable HAIKU_KERNEL_LIBGCC_$targetArch $kernelLibgcc - set_variable HAIKU_CXX_HEADERS_DIR_$targetArch "$cxxHeaders" - set_variable HAIKU_BOOT_LIBGCC_$targetArch $bootLibgcc set_variable HAIKU_BOOT_CXX_HEADERS_DIR_$targetArch "$bootCxxHeaders" + set_variable HAIKU_BOOT_LIBSUPCXX_$targetArch "$bootLibSupCxx" + set_variable HAIKU_BOOT_LIBGCC_$targetArch $bootLibgcc set_variable HAIKU_USE_GCC_GRAPHITE_$targetArch $useGraphite standard_gcc_settings_targetArch=$targetArch @@ -906,15 +821,6 @@ else esac fi - # Get the libgcc objects. We couldn't do that in standard_gcc_settings, - # since we need "ar", which may be set later. - ar=`get_variable HAIKU_AR_$targetArch` - libgcc=`get_variable HAIKU_GCC_LIBGCC_$targetArch` - set_variable HAIKU_GCC_LIBGCC_OBJECTS_$targetArch \ - "`$ar t $libgcc | grep -v eabi.o`" - # Note: We filter out eabi.o. It's present in gcc's libgcc for PPC - # and neither needed nor wanted. - # check whether the Haiku compiler really targets Haiku targetMachine=`get_variable HAIKU_GCC_MACHINE_$targetArch` case "$targetMachine" in @@ -982,14 +888,7 @@ for targetArch in $HAIKU_PACKAGING_ARCHS; do HAIKU_GCC_RAW_VERSION HAIKU_GCC_RAW_VERSION HAIKU_GCC_MACHINE HAIKU_GCC_MACHINE HAIKU_GCC_LIB_DIR HAIKU_GCC_LIB_DIR - HAIKU_GCC_LIBGCC HAIKU_GCC_LIBGCC HAIKU_CPU HAIKU_CPU - HAIKU_STATIC_LIBSTDC++ HAIKU_STATIC_LIBSTDCXX - HAIKU_SHARED_LIBSTDC++ HAIKU_SHARED_LIBSTDCXX - HAIKU_STATIC_LIBSUPC++ HAIKU_STATIC_LIBSUPCXX - HAIKU_SHARED_LIBSUPC++ HAIKU_SHARED_LIBSUPCXX - HAIKU_KERNEL_LIBGCC HAIKU_KERNEL_LIBGCC - HAIKU_KERNEL_LIBSUPC++ HAIKU_KERNEL_LIBSUPCXX HAIKU_BOOT_LIBGCC HAIKU_BOOT_LIBGCC HAIKU_BOOT_LIBSUPC++ HAIKU_BOOT_LIBSUPCXX HAIKU_AR HAIKU_AR @@ -1018,10 +917,7 @@ for targetArch in $HAIKU_PACKAGING_ARCHS; do # For variables that may have long values, distribute them over multiple # lines so that jam doesn't hit the maximum line length. variables=" - HAIKU_GCC_HEADERS_DIR HAIKU_GCC_HEADERS_DIR - HAIKU_C++_HEADERS_DIR HAIKU_CXX_HEADERS_DIR HAIKU_BOOT_C++_HEADERS_DIR HAIKU_BOOT_CXX_HEADERS_DIR - HAIKU_GCC_LIBGCC_OBJECTS HAIKU_GCC_LIBGCC_OBJECTS " set -- $variables while [ $# -ge 2 ]; do