Skip to content

Don't build empty compiler-rt.lib on Windows MSVC at all #28636

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
336 changes: 172 additions & 164 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -945,162 +945,6 @@ then
fi
fi

# If the clang isn't already enabled, check for GCC, and if it is missing, turn
# on clang as a backup.
if [ -z "$CFG_ENABLE_CLANG" ]
then
CFG_GCC_VERSION=$("$CFG_GCC" --version 2>&1)
if [ $? -ne 0 ]
then
step_msg "GCC not installed, will try using Clang"
CFG_ENABLE_CLANG=1
fi
fi

# Okay, at this point, we have made up our minds about whether we are
# going to force CFG_ENABLE_CLANG or not; save the setting if so.
if [ -n "$CFG_ENABLE_CLANG" ]
then
putvar CFG_ENABLE_CLANG
fi

# Same with jemalloc. save the setting here.
if [ -n "$CFG_DISABLE_JEMALLOC" ]
then
putvar CFG_DISABLE_JEMALLOC
fi

if [ -n "$CFG_LLVM_ROOT" -a -z "$CFG_DISABLE_LLVM_VERSION_CHECK" -a -e "$CFG_LLVM_ROOT/bin/llvm-config" ]
then
step_msg "using custom LLVM at $CFG_LLVM_ROOT"

LLVM_CONFIG="$CFG_LLVM_ROOT/bin/llvm-config"
LLVM_VERSION=$($LLVM_CONFIG --version)

case $LLVM_VERSION in
(3.[5-8]*)
msg "found ok version of LLVM: $LLVM_VERSION"
;;
(*)
err "bad LLVM version: $LLVM_VERSION, need >=3.5"
;;
esac
fi

# Even when the user overrides the choice of CC, still try to detect
# clang to disable some clang-specific warnings. We here draw a
# distinction between:
#
# CFG_ENABLE_CLANG : passed --enable-clang, or host "requires" clang,
# CFG_USING_CLANG : compiler (clang / gcc / $CC) looks like clang.
#
# This distinction is important because there are some safeguards we
# would prefer to skip when merely CFG_USING_CLANG is set; but when
# CFG_ENABLE_CLANG is set, that indicates that we are opting into
# running such safeguards.

if [ -n "$CC" ]
then
msg "skipping compiler inference steps; using provided CC=$CC"
CFG_CC="$CC"

CFG_OSX_CC_VERSION=$("$CFG_CC" --version 2>&1 | grep "clang")
if [ $? -eq 0 ]
then
step_msg "note, user-provided CC looks like clang; CC=$CC."
CFG_USING_CLANG=1
putvar CFG_USING_CLANG
fi
else
if [ -n "$CFG_ENABLE_CLANG" ]
then
if [ -z "$CFG_CLANG" ]
then
err "clang requested but not found"
fi
CFG_CC="$CFG_CLANG"
CFG_USING_CLANG=1
putvar CFG_USING_CLANG
else
CFG_CC="gcc"
fi
fi

if [ -n "$CFG_ENABLE_CLANG" ]
then
case "$CC" in
(''|*clang)
CFG_CLANG_REPORTED_VERSION=$($CFG_CC --version | grep version)

if echo $CFG_CLANG_REPORTED_VERSION | grep -q "(based on LLVM "; then
CFG_CLANG_VERSION=$(echo $CFG_CLANG_REPORTED_VERSION | sed 's/.*(based on LLVM \(.*\))/\1/')
elif echo $CFG_CLANG_REPORTED_VERSION | grep -q "Apple LLVM"; then
CFG_OSX_CLANG_VERSION=$(echo $CFG_CLANG_REPORTED_VERSION | sed 's/.*version \(.*\) .*/\1/')
else
CFG_CLANG_VERSION=$(echo $CFG_CLANG_REPORTED_VERSION | sed 's/.*version \(.*\) .*/\1/')
fi

if [ -n "$CFG_OSX_CLANG_VERSION" ]
then
case $CFG_OSX_CLANG_VERSION in
(7.0*)
step_msg "found ok version of APPLE CLANG: $CFG_OSX_CLANG_VERSION"
;;
(*)
err "bad APPLE CLANG version: $CFG_OSX_CLANG_VERSION, need >=7.0"
;;
esac
else
case $CFG_CLANG_VERSION in
(3.2* | 3.3* | 3.4* | 3.5* | 3.6* | 3.7* | 3.8*)
step_msg "found ok version of CLANG: $CFG_CLANG_VERSION"
;;
(*)
err "bad CLANG version: $CFG_CLANG_VERSION, need >=3.0svn"
;;
esac
fi

if [ -z "$CC" ]
then
CFG_CC="clang"
CFG_CXX="clang++"
fi
esac
fi

if [ -n "$CFG_ENABLE_CCACHE" ]
then
if [ -z "$CFG_CCACHE" ]
then
err "ccache requested but not found"
fi

CFG_CC="ccache $CFG_CC"
fi

if [ -z "$CC" -a -z "$CFG_ENABLE_CLANG" -a -z "$CFG_GCC" ]
then
err "either clang or gcc is required"
fi

# All safeguards based on $CFG_ENABLE_CLANG should occur before this
# point in the script; after this point, script logic should inspect
# $CFG_USING_CLANG rather than $CFG_ENABLE_CLANG.

# Set CFG_{CC,CXX,CPP,CFLAGS,CXXFLAGS}
envopt CC
envopt CXX
envopt CPP
envopt CFLAGS
envopt CXXFLAGS

# stdc++ name in use
# used to manage non-standard name (on OpenBSD for example)
program_transform_name=$($CFG_CC -v 2>&1 | sed -n "s/.*--program-transform-name='\([^']*\)'.*/\1/p")
CFG_STDCPP_NAME=$(echo "stdc++" | sed "${program_transform_name}")
putvar CFG_STDCPP_NAME

# a little post-processing of various config values
CFG_PREFIX=${CFG_PREFIX%/}
CFG_MANDIR=${CFG_MANDIR%/}
Expand Down Expand Up @@ -1214,15 +1058,18 @@ $ pacman -R python2 && pacman -S mingw-w64-x86_64-python2
"
fi

# MSVC requires cmake because that's how we're going to build LLVM
probe_need CFG_CMAKE cmake

# There are three builds of cmake on windows: MSVC, MinGW and Cygwin
# The Cygwin build does not have generators for Visual Studio, so
# detect that here and error.
if ! "$CFG_CMAKE" --help | sed -n '/^Generators/,$p' | grep 'Visual Studio' > /dev/null
# Only probe for cmake if we actually need to build LLVM
if [ -z $CFG_LLVM_ROOT ]
then
err "
# MSVC requires cmake because that's how we're going to build LLVM
probe_need CFG_CMAKE cmake

# There are three builds of cmake on windows: MSVC, MinGW and Cygwin
# The Cygwin build does not have generators for Visual Studio, so
# detect that here and error.
if ! "$CFG_CMAKE" --help | sed -n '/^Generators/,$p' | grep 'Visual Studio' > /dev/null
then
err "

cmake does not support Visual Studio generators.

Expand All @@ -1235,6 +1082,7 @@ package instead of cmake:

$ pacman -R cmake && pacman -S mingw-w64-x86_64-cmake
"
fi
fi

# Use the REG program to figure out where VS is installed
Expand Down Expand Up @@ -1300,6 +1148,162 @@ $ pacman -R cmake && pacman -S mingw-w64-x86_64-cmake
esac
done

# If we're not targetting MSVC, and clang isn't already enabled, check for GCC,
# and if it is missing, turn on clang as a backup.
if [ -z "$CFG_MSVC_ROOT" -a -z "$CFG_ENABLE_CLANG" ]
then
CFG_GCC_VERSION=$("$CFG_GCC" --version 2>&1)
if [ $? -ne 0 ]
then
step_msg "GCC not installed, will try using Clang"
CFG_ENABLE_CLANG=1
fi
fi

# Okay, at this point, we have made up our minds about whether we are
# going to force CFG_ENABLE_CLANG or not; save the setting if so.
if [ -n "$CFG_ENABLE_CLANG" ]
then
putvar CFG_ENABLE_CLANG
fi

# Same with jemalloc. save the setting here.
if [ -n "$CFG_DISABLE_JEMALLOC" ]
then
putvar CFG_DISABLE_JEMALLOC
fi

if [ -n "$CFG_LLVM_ROOT" -a -z "$CFG_DISABLE_LLVM_VERSION_CHECK" -a -e "$CFG_LLVM_ROOT/bin/llvm-config" ]
then
step_msg "using custom LLVM at $CFG_LLVM_ROOT"

LLVM_CONFIG="$CFG_LLVM_ROOT/bin/llvm-config"
LLVM_VERSION=$($LLVM_CONFIG --version)

case $LLVM_VERSION in
(3.[5-8]*)
msg "found ok version of LLVM: $LLVM_VERSION"
;;
(*)
err "bad LLVM version: $LLVM_VERSION, need >=3.5"
;;
esac
fi

# Even when the user overrides the choice of CC, still try to detect
# clang to disable some clang-specific warnings. We here draw a
# distinction between:
#
# CFG_ENABLE_CLANG : passed --enable-clang, or host "requires" clang,
# CFG_USING_CLANG : compiler (clang / gcc / $CC) looks like clang.
#
# This distinction is important because there are some safeguards we
# would prefer to skip when merely CFG_USING_CLANG is set; but when
# CFG_ENABLE_CLANG is set, that indicates that we are opting into
# running such safeguards.

if [ -n "$CC" ]
then
msg "skipping compiler inference steps; using provided CC=$CC"
CFG_CC="$CC"

CFG_OSX_CC_VERSION=$("$CFG_CC" --version 2>&1 | grep "clang")
if [ $? -eq 0 ]
then
step_msg "note, user-provided CC looks like clang; CC=$CC."
CFG_USING_CLANG=1
putvar CFG_USING_CLANG
fi
else
if [ -n "$CFG_ENABLE_CLANG" ]
then
if [ -z "$CFG_CLANG" ]
then
err "clang requested but not found"
fi
CFG_CC="$CFG_CLANG"
CFG_USING_CLANG=1
putvar CFG_USING_CLANG
else
CFG_CC="gcc"
fi
fi

if [ -n "$CFG_ENABLE_CLANG" ]
then
case "$CC" in
(''|*clang)
CFG_CLANG_REPORTED_VERSION=$($CFG_CC --version | grep version)

if echo $CFG_CLANG_REPORTED_VERSION | grep -q "(based on LLVM "; then
CFG_CLANG_VERSION=$(echo $CFG_CLANG_REPORTED_VERSION | sed 's/.*(based on LLVM \(.*\))/\1/')
elif echo $CFG_CLANG_REPORTED_VERSION | grep -q "Apple LLVM"; then
CFG_OSX_CLANG_VERSION=$(echo $CFG_CLANG_REPORTED_VERSION | sed 's/.*version \(.*\) .*/\1/')
else
CFG_CLANG_VERSION=$(echo $CFG_CLANG_REPORTED_VERSION | sed 's/.*version \(.*\) .*/\1/')
fi

if [ -n "$CFG_OSX_CLANG_VERSION" ]
then
case $CFG_OSX_CLANG_VERSION in
(7.0*)
step_msg "found ok version of APPLE CLANG: $CFG_OSX_CLANG_VERSION"
;;
(*)
err "bad APPLE CLANG version: $CFG_OSX_CLANG_VERSION, need >=7.0"
;;
esac
else
case $CFG_CLANG_VERSION in
(3.2* | 3.3* | 3.4* | 3.5* | 3.6* | 3.7* | 3.8*)
step_msg "found ok version of CLANG: $CFG_CLANG_VERSION"
;;
(*)
err "bad CLANG version: $CFG_CLANG_VERSION, need >=3.0svn"
;;
esac
fi

if [ -z "$CC" ]
then
CFG_CC="clang"
CFG_CXX="clang++"
fi
esac
fi

if [ -n "$CFG_ENABLE_CCACHE" ]
then
if [ -z "$CFG_CCACHE" ]
then
err "ccache requested but not found"
fi

CFG_CC="ccache $CFG_CC"
fi

if [ -z "$CFG_MSVC_ROOT" -a -z "$CC" -a -z "$CFG_ENABLE_CLANG" -a -z "$CFG_GCC" ]
then
err "either clang or gcc is required"
fi

# All safeguards based on $CFG_ENABLE_CLANG should occur before this
# point in the script; after this point, script logic should inspect
# $CFG_USING_CLANG rather than $CFG_ENABLE_CLANG.

# Set CFG_{CC,CXX,CPP,CFLAGS,CXXFLAGS}
envopt CC
envopt CXX
envopt CPP
envopt CFLAGS
envopt CXXFLAGS

# stdc++ name in use
# used to manage non-standard name (on OpenBSD for example)
program_transform_name=$($CFG_CC -v 2>&1 | sed -n "s/.*--program-transform-name='\([^']*\)'.*/\1/p")
CFG_STDCPP_NAME=$(echo "stdc++" | sed "${program_transform_name}")
putvar CFG_STDCPP_NAME

if [ -n "$CFG_PERF" ]
then
HAVE_PERF_LOGFD=`$CFG_PERF stat --log-fd 2>&1 | grep 'unknown option'`
Expand Down Expand Up @@ -1418,6 +1422,10 @@ then
msg "git: submodule deinit src/jemalloc"
"${CFG_GIT}" submodule deinit src/jemalloc
fi
if [ -n "${CFG_MSVC_ROOT}" ]; then
msg "git: submodule deinit src/compiler-rt"
"${CFG_GIT}" submodule deinit src/compiler-rt
fi

msg "git: submodule update"
"${CFG_GIT}" submodule update
Expand Down
4 changes: 3 additions & 1 deletion mk/platform.mk
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,9 @@ CFG_RLIB_GLOB=lib$(1)-*.rlib
include $(wildcard $(CFG_SRC_DIR)mk/cfg/*.mk)

define ADD_INSTALLED_OBJECTS
INSTALLED_OBJECTS_$(1) += $$(call CFG_STATIC_LIB_NAME_$(1),compiler-rt)
ifneq ($$(findstring msvc,$(1)),msvc)
INSTALLED_OBJECTS_$(1) += $$(call CFG_STATIC_LIB_NAME_$(1),compiler-rt)
endif
endef

$(foreach target,$(CFG_TARGET), \
Expand Down
Loading