Skip to content

Commit

Permalink
try adding gcc suffix support 1
Browse files Browse the repository at this point in the history
Might also help with Homebrew gcc builds,
ref: 5add616
  • Loading branch information
vszakats committed Oct 10, 2023
1 parent b4b35fc commit c13d39f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
24 changes: 15 additions & 9 deletions _build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions _ci-linux-debian.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ elif [[ "${CW_CONFIG:-}" = *'linux'* ]]; then
fi
if [[ "${CW_CONFIG:-}" = *'gcc'* ]]; then
extra="${extra} gcc${GCCSUFF}"
CW_CCSUFFIX="${GCCSUFF}"
fi
fi

Expand Down

0 comments on commit c13d39f

Please sign in to comment.