gcc-clang-compatibility: Test that gcc compiled objs can be linked with

clang and viceversa.
This commit is contained in:
Jesus Checa Hidalgo 2022-10-17 12:15:28 +02:00
commit 8454ab8df6
3 changed files with 52 additions and 0 deletions

View file

@ -0,0 +1,6 @@
#include <iostream>
int main(){
std::cout << "Hello world!\n";
return 0;
}

View file

@ -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"

15
gcc-clang-compatibility/test.sh Executable file
View file

@ -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}/*