configure & build: Rework legacy GCC detection to parse versions outside of Jam.

Jam comparison logic is string-based, and so was detecting GCC >= 10
as being < 2. This rectifies that by removing the GCC version parsing
from Jam logic entirely, and setting various BuildConfig variables
instead.

Change-Id: I0c0ae3b9002fb5e77f9ca7a78600c91871657f03
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3293
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>
Reviewed-by: Alex von Gluck IV <kallisti5@unixzen.com>
This commit is contained in:
Augustin Cavalier 2020-10-06 23:46:18 -04:00 committed by Alex von Gluck IV
parent a3f0a36a79
commit 47320dd0ab
19 changed files with 54 additions and 74 deletions

View File

@ -7,18 +7,13 @@ rule ArchitectureSetup architecture
# architecture), if this is the first invocation of the rule, and adds
# the architecture to HAIKU_ARCHS, if not yet contained.
# analyze GCC version
local gccVersion
= [ FAnalyzeGCCVersion HAIKU_GCC_RAW_VERSION_$(architecture) ] ;
HAIKU_GCC_VERSION_$(architecture) = $(gccVersion) ;
# enable GCC -pipe option, if requested
local ccBaseFlags ;
if $(HAIKU_USE_GCC_PIPE) = 1 {
ccBaseFlags = -pipe ;
}
if $(gccVersion[1]) >= 3 {
if $(HAIKU_CC_IS_LEGACY_GCC_$(architecture)) != 1 {
# disable strict aliasing on anything newer than gcc 2 as it may lead to
# unexpected results.
# TODO: remove the -fno-strict-aliasing option when all code has been
@ -122,7 +117,7 @@ rule ArchitectureSetup architecture
HAIKU_WERROR_FLAGS_$(architecture) = ;
if $(gccVersion[1]) >= 4 {
if $(HAIKU_CC_IS_LEGACY_GCC_$(architecture)) != 1 {
# TODO: Remove all these.
HAIKU_WERROR_FLAGS_$(architecture) += -Wno-error=unused-but-set-variable
-Wno-error=deprecated -Wno-error=deprecated-declarations
@ -149,7 +144,7 @@ rule ArchitectureSetup architecture
# TODO: Temporary work-around. Should be defined in the compiler specs
HAIKU_LINKFLAGS_$(architecture) += -Xlinker --no-undefined ;
if $(gccVersion[1]) < 3 {
if $(HAIKU_CC_IS_LEGACY_GCC_$(architecture)) = 1 {
HAIKU_DEFINES_$(architecture) += _BEOS_R5_COMPATIBLE_ ;
}
@ -222,7 +217,6 @@ rule KernelArchitectureSetup architecture
HAIKU_KERNEL_ARCH = $(HAIKU_ARCH) ;
local gccVersion = $(HAIKU_GCC_VERSION_$(architecture)) ;
local cpu = $(HAIKU_CPU_$(architecture)) ;
switch $(cpu) {
@ -352,8 +346,8 @@ rule KernelArchitectureSetup architecture
# C/C++ flags
local ccBaseFlags = -finline -fno-builtin ;
if $(gccVersion[1]) >= 4 {
if $(HAIKU_CC_IS_CLANG_$(architecture)) != 1 {
if $(HAIKU_CC_IS_LEGACY_GCC_$(architecture)) != 1 {
if ! $(HAIKU_CC_IS_CLANG_$(architecture)) {
# Clang does not yet understand this flag.
ccBaseFlags += -fno-semantic-interposition ;
}
@ -363,7 +357,8 @@ rule KernelArchitectureSetup architecture
local c++BaseFlags = $(ccBaseFlags) -fno-exceptions ;
if $(gccVersion[1]) >= 3 && $(HAIKU_CC_IS_CLANG_$(architecture)) != 1 {
if $(HAIKU_CC_IS_LEGACY_GCC_$(architecture)) != 1
&& $(HAIKU_CC_IS_CLANG_$(architecture)) != 1 {
c++BaseFlags += -fno-use-cxa-atexit ;
}
@ -501,7 +496,7 @@ rule KernelArchitectureSetup architecture
} else {
HAIKU_BOOT_$(bootTarget:U)_LDFLAGS += -m elf_i386_haiku ;
}
if $(gccVersion[1]) >= 3 {
if $(HAIKU_CC_IS_LEGACY_GCC_$(architecture)) != 1 {
HAIKU_BOOT_$(bootTarget:U)_CCFLAGS += -Wno-error=main -m32 ;
HAIKU_BOOT_$(bootTarget:U)_C++FLAGS += -Wno-error=main -m32 ;
}
@ -514,7 +509,7 @@ rule KernelArchitectureSetup architecture
} else {
HAIKU_BOOT_$(bootTarget:U)_LDFLAGS += -m elf_i386_haiku ;
}
if $(gccVersion[1]) >= 3 {
if $(HAIKU_CC_IS_LEGACY_GCC_$(architecture)) != 1 {
HAIKU_BOOT_$(bootTarget:U)_CCFLAGS += -Wno-error=main -m32 ;
HAIKU_BOOT_$(bootTarget:U)_C++FLAGS += -Wno-error=main -m32 ;
}
@ -606,8 +601,7 @@ rule ArchitectureSetupWarnings architecture
# Work-around for GCC 2 problem -- despite -Wno-multichar it reports
# multichar warnings in headers/private/kernel/debugger_keymaps.h included
# by src/system/kernel/arch/x86/arch_debug_console.cpp.
local gccVersion = $(HAIKU_GCC_VERSION_$(architecture)) ;
if $(gccVersion[1]) = 2 {
if $(HAIKU_CC_IS_LEGACY_GCC_$(architecture)) = 1 {
local file = <src!system!kernel!arch!x86>arch_debug_console.o ;
WARNINGS on $(file) = $(WARNINGS) ;
}

View File

@ -447,7 +447,7 @@ rule InitArchitectureBuildFeatures architecture
# Add all secondary architectures as build features (with prefix).
EnableBuildFeatures secondary_$(TARGET_PACKAGING_ARCHS[2-]) ;
if $(TARGET_GCC_VERSION_$(architecture)[1]) = 2 {
if $(TARGET_CC_IS_LEGACY_GCC_$(architecture)) = 1 {
EnableBuildFeatures gcc2 ;
}

View File

@ -239,12 +239,9 @@ HOST_ARCH ?= $(HOST_CPU) ;
HOST_ARCHS = $(HOST_ARCH) ;
HOST_KERNEL_ARCH = host ;
# analyze GCC version
HOST_GCC_VERSION = [ FAnalyzeGCCVersion HOST_GCC_RAW_VERSION ] ;
# set packaging architecture
HOST_PACKAGING_ARCH ?= $(HOST_CPU) ;
if $(HOST_PACKAGING_ARCH) = x86 && $(HOST_GCC_VERSION[1]) = 2 {
if $(HOST_PACKAGING_ARCH) = x86 && $(HOST_CC_IS_LEGACY_GCC) = 1 {
HOST_PACKAGING_ARCH = x86_gcc2 ;
}
HOST_PACKAGING_ARCHS = $(HOST_PACKAGING_ARCH) ;
@ -276,7 +273,7 @@ HOST_C++FLAGS += -Wno-multichar ;
HOST_PIC_CCFLAGS += -fPIC ;
HOST_PIC_C++FLAGS += -fPIC ;
if $(HOST_GCC_VERSION[1]) >= 3 {
if $(HOST_CC_IS_LEGACY_GCC) != 1 {
HOST_GCC_BASE_FLAGS += -fno-strict-aliasing -fno-delete-null-pointer-checks ;
}
@ -306,7 +303,7 @@ if $(HOST_ARCH) = m68k {
if $(HOST_PLATFORM) != darwin {
# fix for new changes to DSO linking policies
HOST_LINKFLAGS += -Xlinker --no-as-needed ;
if $(HOST_GCC_VERSION[1]) >= 3 {
if $(HOST_CC_IS_LEGACY_GCC) != 1 {
HOST_LINKFLAGS += -Wl,--copy-dt-needed-entries ;
}
}
@ -382,7 +379,7 @@ HOST_LIBBE = libbe_build.so ;
if $(HOST_PLATFORM_HAIKU_COMPATIBLE) {
# the C++ standard and support libraries
if $(HOST_GCC_VERSION[1]) < 3 {
if $(HOST_CC_IS_LEGACY_GCC) = 1 {
HOST_LIBSTDC++ = stdc++.r4 ;
HOST_LIBSUPC++ = ;
} else {
@ -418,7 +415,7 @@ if $(HOST_PLATFORM_HAIKU_COMPATIBLE) {
HOST_PTHREAD_LINKFLAGS = -pthread ;
# the C++ support library
if $(HOST_GCC_VERSION[1]) < 3 {
if $(HOST_CC_IS_LEGACY_GCC) = 1 {
HOST_LIBSUPC++ = ;
} else {
HOST_LIBSUPC++ = supc++ ;
@ -586,10 +583,12 @@ local buildVars =
;
local archDependentBuildVars =
ARCH CPU GCC_VERSION
ARCH CPU
AR CC C++ ELFEDIT LD OBJCOPY RANLIB STRIP
CC_IS_LEGACY_GCC CC_IS_CLANG
ARFLAGS ASFLAGS UNARFLAGS CPPFLAGS CCFLAGS C++FLAGS HDRS LDFLAGS
LINK LINKFLAGS

View File

@ -208,40 +208,12 @@ rule SetPlatformCompatibilityFlagVariables
?= $($(varPrefix)_PLATFORM_HAIKU_COMPATIBLE) ;
}
rule FAnalyzeGCCVersion
{
# FAnalyzeGCCVersion <rawVersionVariable> ;
#
local varName = $(1) ;
local rawVersion = $($(varName)) ;
if ! $(rawVersion) {
ECHO "Variable $(varName) not set. Please run ./configure or" ;
EXIT "specify it manually." ;
}
local version = ;
# split the raw version string at `.' and `-' characters
while $(rawVersion) {
local split = [ Match "([^.-]*)[.-](.*)" : $(rawVersion) ] ;
if $(split) {
version += $(split[1]) ;
rawVersion = $(split[2]) ;
} else {
version += $(rawVersion) ;
rawVersion = ;
}
}
return $(version) ;
}
rule SetIncludePropertiesVariables prefix : suffix
{
# SetIncludePropertiesVariables <prefix> : <suffix> ;
#
suffix = $(suffix:E=) ;
if $($(prefix)_GCC_VERSION$(suffix)[1]) < 4 {
if $($(prefix)_CC_IS_LEGACY_GCC$(suffix)) {
$(prefix)_INCLUDES_SEPARATOR$(suffix) = -I- ;
$(prefix)_LOCAL_INCLUDES_OPTION$(suffix) = -I ;
$(prefix)_SYSTEM_INCLUDES_OPTION$(suffix) = -I ;

View File

@ -41,11 +41,10 @@ if [ IsOptionalHaikuImagePackageAdded BeBook ] {
# BeOSCompatibility
if [ IsOptionalHaikuImagePackageAdded BeOSCompatibility ] {
if $(TARGET_ARCH) != x86 {
if $(TARGET_ARCH) != x86
|| $(TARGET_CC_IS_LEGACY_GCC_$(TARGET_PACKAGING_ARCH)) != 1 {
Echo "No optional package BeOSCompatibility available for"
"$(TARGET_ARCH)" ;
} else if $(TARGET_GCC_VERSION_$(TARGET_PACKAGING_ARCH)[1]) >= 4 {
Echo "No optional package BeOSCompatibility available for gcc4" ;
} else {
Echo "Warning: Adding BeOS compatibility symlinks. This will go away."
"Please fix your apps!" ;

View File

@ -93,7 +93,7 @@ AddLibrariesToPackage lib
: [ HaikuImageGetSystemLibs ] [ HaikuImageGetPrivateSystemLibs ] ;
# libnetwork.so replaces quite a few libraries
if $(HAIKU_GCC_VERSION_$(architecture)[1]) = 2 {
if $(HAIKU_CC_IS_LEGACY_GCC_$(architecture)) = 1 {
local libNetworkAliases = libsocket.so libbind.so libnet.so ;
local lib ;
for lib in $(libNetworkAliases) {

View File

@ -87,7 +87,7 @@ AddLibrariesToPackage lib
: [ HaikuImageGetSystemLibs ] [ HaikuImageGetPrivateSystemLibs ] ;
# libnetwork.so replaces quite a few libraries
if $(HAIKU_GCC_VERSION_$(architecture)[1]) = 2 {
if $(HAIKU_CC_IS_LEGACY_GCC_$(architecture)) = 1 {
local libNetworkAliases = libsocket.so libbind.so libnet.so ;
local lib ;
for lib in $(libNetworkAliases) {

View File

@ -93,7 +93,7 @@ for stage in _stage0 _stage1 "" {
if $(stage) != _stage0 {
# cpp headers
if $(HAIKU_GCC_VERSION_$(architecture)[1]) = 2 {
if $(HAIKU_CC_IS_LEGACY_GCC_$(architecture)) = 1 {
# GCC 2 only -- for GCC 4 they come with the DevelopmentBase package
CopyDirectoryToPackage $(developCrossHeadersDirTokens) c++
: [ FDirName $(HAIKU_TOP) headers cpp ] : 2.95.3 ;

View File

@ -79,7 +79,7 @@ AddHeaderDirectoryToPackage compatibility bsd : bsd ;
AddHeaderDirectoryToPackage compatibility gnu : gnu ;
# cpp headers
if $(HAIKU_GCC_VERSION_$(architecture)[1]) = 2 {
if $(HAIKU_CC_IS_LEGACY_GCC_$(architecture)) = 1 {
# GCC 2 only -- for GCC 4 they come with the gcc package
CopyDirectoryToPackage develop headers c++
: [ FDirName $(HAIKU_TOP) headers cpp ] : 2.95.3 ;

View File

@ -48,7 +48,7 @@ AddFilesToPackage develop lib $(architecture)
# ABI independent stuff
# cpp headers
if $(HAIKU_GCC_VERSION_$(architecture)[1]) = 2 {
if $(HAIKU_CC_IS_LEGACY_GCC_$(architecture)) = 1 {
# GCC 2 only -- for GCC 4 they come with the gcc package
CopyDirectoryToPackage develop headers c++
: [ FDirName $(HAIKU_TOP) headers cpp ] : 2.95.3 ;

View File

@ -10,7 +10,7 @@ AddLibrariesToPackage lib $(architecture)
: [ HaikuImageGetSystemLibs ] [ HaikuImageGetPrivateSystemLibs ] ;
# libnetwork.so replaces quite a few libraries
if $(HAIKU_GCC_VERSION_$(architecture)[1]) = 2 {
if $(HAIKU_CC_IS_LEGACY_GCC_$(architecture)) = 1 {
local libNetworkAliases = libsocket.so libbind.so libnet.so ;
local lib ;
for lib in $(libNetworkAliases) {

View File

@ -11,7 +11,7 @@ AddLibrariesToPackage lib $(architecture)
: [ HaikuImageGetSystemLibs ] [ HaikuImageGetPrivateSystemLibs ] ;
# libnetwork.so replaces quite a few libraries
if $(HAIKU_GCC_VERSION_$(architecture)[1]) = 2 {
if $(HAIKU_CC_IS_LEGACY_GCC_$(architecture)) = 1 {
local libNetworkAliases = libsocket.so libbind.so libnet.so ;
local lib ;
for lib in $(libNetworkAliases) {

20
configure vendored
View File

@ -239,6 +239,19 @@ valid_toolchain()
return 1
}
# is_legacy_gcc
#
# Determines if the specified GCC version is a "legacy" (i.e. GCC < 4) one.
#
is_legacy_gcc()
{
if [ `echo $1 | cut -d'.' -f1` -lt 4 ]; then
echo 1
else
echo 0
fi
}
# standard_gcc_settings
#
# Sets the variables for a GCC platform.
@ -331,6 +344,8 @@ standard_gcc_settings()
set_variable HAIKU_CPU_$targetArch $targetCpu
get_build_tool_path CC_$targetArch "$gcc"
set_variable HAIKU_CC_IS_LEGACY_GCC_$targetArch \
`is_legacy_gcc $gccRawVersion`
set_variable HAIKU_CC_IS_CLANG_$targetArch $useClang
set_variable HAIKU_GCC_RAW_VERSION_$targetArch $gccRawVersion
set_variable HAIKU_GCC_MACHINE_$targetArch $gccMachine
@ -608,6 +623,7 @@ fi
# exported (BuildSetup) default parameter values
#
HOST_GCC_RAW_VERSION=`$CC -dumpversion`
HOST_CC_IS_LEGACY_GCC=`is_legacy_gcc $HOST_GCC_RAW_VERSION`
HOST_GCC_MACHINE=`$CC -dumpmachine`
HAIKU_INCLUDE_SOURCES=0
HAIKU_INCLUDE_3RDPARTY=0
@ -1082,7 +1098,7 @@ HAIKU_HOST_BUILD_ONLY ?= "${HAIKU_HOST_BUILD_ONLY}" ;
JAMSHELL ?= ${JAMSHELL} -c ;
HOST_CC ?= ${CC} ;
HOST_GCC_RAW_VERSION ?= ${HOST_GCC_RAW_VERSION} ;
HOST_CC_IS_LEGACY_GCC ?= ${HOST_CC_IS_LEGACY_GCC} ;
HOST_GCC_MACHINE ?= ${HOST_GCC_MACHINE} ;
HOST_LD ?= ${HOST_GCC_LD} ;
HOST_OBJCOPY ?= ${HOST_GCC_OBJCOPY} ;
@ -1103,11 +1119,11 @@ EOF
for targetArch in $HAIKU_PACKAGING_ARCHS; do
variables="
HAIKU_CC HAIKU_CC
HAIKU_CC_IS_LEGACY_GCC HAIKU_CC_IS_LEGACY_GCC
HAIKU_CC_IS_CLANG HAIKU_CC_IS_CLANG
HAIKU_USE_GCC_GRAPHITE HAIKU_USE_GCC_GRAPHITE
HAIKU_CPU HAIKU_CPU
HAIKU_GCC_MACHINE HAIKU_GCC_MACHINE
HAIKU_GCC_RAW_VERSION HAIKU_GCC_RAW_VERSION
HAIKU_GCC_LIB_DIR HAIKU_GCC_LIB_DIR
HAIKU_BOOT_LIBGCC HAIKU_BOOT_LIBGCC
HAIKU_BOOT_LIBSUPC++ HAIKU_BOOT_LIBSUPCXX

View File

@ -3,7 +3,7 @@ UseBuildFeatureHeaders glu ;
UseBuildFeatureHeaders mesa ;
# For GCC2
if $(TARGET_GCC_VERSION_$(TARGET_PACKAGING_ARCH)[1]) < 3 {
if $(TARGET_CC_IS_LEGACY_GCC_$(TARGET_PACKAGING_ARCH)) = 1 {
SubDirC++Flags --no-warnings ;
}

View File

@ -4,7 +4,7 @@ SubDirHdrs [ FDirName $(SUBDIR) $(DOTDOT) shared ] ;
AddResources PNGTranslator : PNGTranslator.rdef ;
if $(TARGET_GCC_VERSION_$(TARGET_PACKAGING_ARCH)[1]) = 2 {
if $(TARGET_CC_IS_LEGACY_GCC_$(TARGET_PACKAGING_ARCH)) = 1 {
SubDirCcFlags -DPNG_NO_PEDANTIC_WARNINGS ;
}
@ -17,7 +17,7 @@ for architectureObject in [ MultiArchSubDirSetup ] {
Includes [ FGristFiles PNGTranslator.cpp PNGView.cpp ]
: [ BuildFeatureAttribute libpng : headers ] ;
Translator [ MultiArchDefaultGristFiles PNGTranslator ] :
Translator [ MultiArchDefaultGristFiles PNGTranslator ] :
PNGMain.cpp
PNGTranslator.cpp
PNGView.cpp

View File

@ -6,7 +6,7 @@ SEARCH_SOURCE += [ FDirName $(SUBDIR) mesh ] ;
SEARCH_SOURCE += [ FDirName $(SUBDIR) texture ] ;
# For GCC2
if $(TARGET_GCC_VERSION_$(TARGET_PACKAGING_ARCH)[1]) < 3 {
if $(TARGET_CC_IS_LEGACY_GCC_$(TARGET_PACKAGING_ARCH)) = 1 {
SubDirC++Flags --no-warnings ;
}

View File

@ -250,7 +250,7 @@ actions AtariBootPrgLd
local extraSources = ;
if $(TARGET_GCC_VERSION_$(TARGET_PACKAGING_ARCH)[1]) = 2 {
if $(TARGET_CC_IS_LEGACY_GCC_$(TARGET_PACKAGING_ARCH)) = 1 {
extraSources += atomic.S ;
}

View File

@ -13,7 +13,7 @@ for architectureObject in [ MultiArchSubDirSetup x86 x86_gcc2 ] {
SEARCH_SOURCE += [ FDirName $(SUBDIR) $(DOTDOT) generic ] ;
local compatibilitySources ;
if $(TARGET_GCC_VERSION_$(architecture)[1]) = 2 {
if $(TARGET_CC_IS_LEGACY_GCC_$(architecture)) = 1 {
compatibilitySources =
compatibility.c
;

View File

@ -20,7 +20,7 @@ DEFINES += HAIKU_BUILD_COMPATIBILITY_H __STRICT_ANSI__ ;
defines = [ FDefines $(defines) ] ;
local c++flags = ;
if $(HOST_GCC_VERSION[1]) >= 3 {
if $(HOST_CC_IS_LEGACY_GCC) != 1 {
c++flags += -std=c++11 ;
}