diff --git a/gcc-clang-compatibility/hello.cpp b/gcc-clang-compatibility/hello.cpp new file mode 100644 index 0000000..8f7c3e9 --- /dev/null +++ b/gcc-clang-compatibility/hello.cpp @@ -0,0 +1,6 @@ +#include + +int main(){ + std::cout << "Hello world!\n"; + return 0; +} diff --git a/gcc-clang-compatibility/main.fmf b/gcc-clang-compatibility/main.fmf new file mode 100644 index 0000000..b880df5 --- /dev/null +++ b/gcc-clang-compatibility/main.fmf @@ -0,0 +1,31 @@ +summary: Test that both gcc/clang compile/link compatibility. +description: + Build an object file with g++, link it with clang++ and viceversa, to ensure + that objects compiled with one can be linked with the other. +test: "$WITH_SCL ./test.sh" +framework: shell +tier: 1 +component: + - llvm-toolset + - clang +extra-summary: /tools/clang/gcc-clang-compatibility +extra-task: /tools/clang/gcc-clang-compatibility + +require: + - gcc-c++ + +adjust: + - require+: + - clang + when: collection is not defined + + # Requirements for SCL-ized LLVM + - require+: + - llvm-toolset-13.0-clang + when: "collection == llvm-toolset-13.0" + - require+: + - llvm-toolset-14.0-clang + when: "collection == llvm-toolset-14.0" + - require+: + - llvm-toolset-15.0-clang + when: "collection == llvm-toolset-15.0" diff --git a/gcc-clang-compatibility/test.sh b/gcc-clang-compatibility/test.sh new file mode 100755 index 0000000..e2d4b0d --- /dev/null +++ b/gcc-clang-compatibility/test.sh @@ -0,0 +1,15 @@ +#!/bin/sh -eux + +tmp=$(mktemp -d) + +# Build the source with GCC, link it with clang +g++ -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 +${tmp}/hello | grep "Hello world" +rm -rf ${tmp}/*