gcc-clang-compatibility: Add support for gcc-toolset installations
clang may use a gcc from gcc-toolset instead the system version. In that case we need to test the compatibility with that one, not with the system based gcc.
This commit is contained in:
parent
5a8ea6a930
commit
1e0115c194
1 changed files with 13 additions and 2 deletions
|
|
@ -2,14 +2,25 @@
|
|||
|
||||
tmp=$(mktemp -d)
|
||||
|
||||
# clang not necessarily depends on system gcc. It might depend on gcc from
|
||||
# gcc-toolset-XX, in such case we need to test the compatibility with that one.
|
||||
# We can get that from `clang -v` output.
|
||||
TOOLSET=$(clang -v |& grep "Selected GCC installation" | grep -P -o '(dev|gcc-)toolset-[0-9]*') ||:
|
||||
if [[ "x" = "x${TOOLSET}" ]]; then
|
||||
GCC="g++"
|
||||
else
|
||||
GCC="scl enable ${TOOLSET} -- g++"
|
||||
echo "Testing with g++ from ${TOOLSET}"
|
||||
fi
|
||||
|
||||
# Build the source with GCC, link it with clang
|
||||
g++ -c hello.cpp -o ${tmp}/hello.o
|
||||
${GCC} -c hello.cpp -o ${tmp}/hello.o
|
||||
clang++ -o ${tmp}/hello ${tmp}/hello.o
|
||||
${tmp}/hello | grep "Hello world"
|
||||
rm -rf ${tmp}/*
|
||||
|
||||
# Build the source with clang, link it with GCC
|
||||
clang++ -c hello.cpp -o ${tmp}/hello.o
|
||||
g++ -o ${tmp}/hello ${tmp}/hello.o
|
||||
${GCC} -o ${tmp}/hello ${tmp}/hello.o
|
||||
${tmp}/hello | grep "Hello world"
|
||||
rm -rf ${tmp}/*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue