From c13d39f5ffb286d0320d19819cad2721c8a7a5e5 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Tue, 10 Oct 2023 21:14:17 +0000 Subject: [PATCH] try adding gcc suffix support 1 Might also help with Homebrew gcc builds, ref: 5add6165606c80b193b661a71f2b400b5ffc298e --- _build.sh | 24 +++++++++++++++--------- _ci-linux-debian.sh | 1 + 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/_build.sh b/_build.sh index acafae315..04ebea037 100755 --- a/_build.sh +++ b/_build.sh @@ -64,7 +64,7 @@ set -o xtrace -o errexit -o nounset; [ -n "${BASH:-}${ZSH_NAME:-}" ] && set -o p # Number of parallel make jobs. Default: 2 # # CW_CCSUFFIX -# llvm/clang suffix. E.g. '-8' for clang-8. +# llvm/clang and gcc suffix. E.g. '-8' for clang-8. # Optional. Default: (empty) # # CW_REVISION @@ -683,14 +683,14 @@ build_single_target() { _CCPREFIX='musl-' fi - ccver="$("${_CCPREFIX}gcc" -dumpversion)" + ccver="$("${_CCPREFIX}gcc${_CCSUFFIX}" -dumpversion)" if [ "${_CRT}" = 'ucrt' ]; then # Create specs files that overrides msvcrt with ucrt. We need this # for gcc when building against UCRT. # https://stackoverflow.com/questions/57528555/how-do-i-build-against-the-ucrt-with-mingw-w64 _GCCSPECS="$(pwd)/gcc-specs-ucrt" - "${_CCPREFIX}gcc" -dumpspecs | sed 's/-lmsvcrt/-lucrt/g' > "${_GCCSPECS}" + "${_CCPREFIX}gcc${_CCSUFFIX}" -dumpspecs | sed 's/-lmsvcrt/-lucrt/g' > "${_GCCSPECS}" fi fi @@ -966,7 +966,7 @@ build_single_target() { # Use it with CMake and OpenSSL's proprietary build system. _CFLAGS_GLOBAL_CMAKE="${_CFLAGS_GLOBAL_CMAKE} -Wno-unused-command-line-argument" else - _CC_GLOBAL="${_CCPREFIX}gcc" + _CC_GLOBAL="${_CCPREFIX}gcc${_CCSUFFIX}" if [ "${_OS}" = 'win' ]; then # Also accepted on linux, but does not seem to make any difference @@ -984,14 +984,16 @@ build_single_target() { _CFLAGS_GLOBAL="${_OPTM} ${_CFLAGS_GLOBAL}" fi - _CMAKE_GLOBAL="${_CMAKE_GLOBAL} -DCMAKE_C_COMPILER=${_CCPREFIX}gcc" + _CMAKE_GLOBAL="${_CMAKE_GLOBAL} -DCMAKE_C_COMPILER=${_CCPREFIX}gcc${_CCSUFFIX}" if [ "${_CCPREFIX}" != 'musl-' ]; then - _CMAKE_CXX_GLOBAL="${_CMAKE_CXX_GLOBAL} -DCMAKE_CXX_COMPILER=${_CCPREFIX}g++" + _CMAKE_CXX_GLOBAL="${_CMAKE_CXX_GLOBAL} -DCMAKE_CXX_COMPILER=${_CCPREFIX}g++${_CCSUFFIX}" else _CMAKE_CXX_GLOBAL="${_CMAKE_CXX_GLOBAL} -DCMAKE_CXX_COMPILER=g++" fi _LD='ld' + + _BINUTILS_SUFFIX="${_CCSUFFIX}" fi if [ "${_CRT}" = 'musl' ] && [ "${_DISTRO}" = 'debian' ]; then @@ -1043,6 +1045,10 @@ build_single_target() { fi fi + _BINCORE_SUFFIX="${_BINUTILS_SUFFIX}" + + [ "${_CC}" = 'gcc' ] && _BINUTILS_SUFFIX='' + export _STRIP export _STRIPFLAGS_BIN export _STRIPFLAGS_DYN @@ -1103,9 +1109,9 @@ build_single_target() { # or clang-cl). Workaround: create an alias for it: ln -s -f "/usr/bin/clang${_CCSUFFIX}" "$(pwd)/clang" fi - export AR="${_BINUTILS_PREFIX}ar${_BINUTILS_SUFFIX}" - export NM="${_BINUTILS_PREFIX}nm${_BINUTILS_SUFFIX}" - export RANLIB="${_BINUTILS_PREFIX}ranlib${_BINUTILS_SUFFIX}" + export AR="${_BINUTILS_PREFIX}ar${_BINCORE_SUFFIX}" + export NM="${_BINUTILS_PREFIX}nm${_BINCORE_SUFFIX}" + export RANLIB="${_BINUTILS_PREFIX}ranlib${_BINCORE_SUFFIX}" # ar wrapper to normalize created libs if [ "${CW_DEV_CROSSMAKE_REPRO:-}" = '1' ]; then diff --git a/_ci-linux-debian.sh b/_ci-linux-debian.sh index 332a97b6d..0be3bc644 100755 --- a/_ci-linux-debian.sh +++ b/_ci-linux-debian.sh @@ -47,6 +47,7 @@ elif [[ "${CW_CONFIG:-}" = *'linux'* ]]; then fi if [[ "${CW_CONFIG:-}" = *'gcc'* ]]; then extra="${extra} gcc${GCCSUFF}" + CW_CCSUFFIX="${GCCSUFF}" fi fi