diff --git a/tests/openmp-rpm/main.fmf b/tests/openmp-rpm/main.fmf new file mode 100644 index 0000000..ffc4bf4 --- /dev/null +++ b/tests/openmp-rpm/main.fmf @@ -0,0 +1,6 @@ +summary: Test build a simple RPM package to ensure that -fopenmp works +require: + - dnf + - dnf-plugins-core + - rpm-build +test: ./runtest.sh diff --git a/tests/openmp-rpm/runtest.sh b/tests/openmp-rpm/runtest.sh new file mode 100755 index 0000000..4fe82e9 --- /dev/null +++ b/tests/openmp-rpm/runtest.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +set -ex + +dnf -y build-dep test.spec +rpmbuild --define '_sourcedir .' --define '_builddir .' -bb test.spec diff --git a/tests/openmp-rpm/test.c b/tests/openmp-rpm/test.c new file mode 100644 index 0000000..b20d164 --- /dev/null +++ b/tests/openmp-rpm/test.c @@ -0,0 +1,7 @@ +int main(int argc, char **argv) { + int res = 1; +#pragma omp parallel +#pragma omp single + res = 0; + return res; +} diff --git a/tests/openmp-rpm/test.spec b/tests/openmp-rpm/test.spec new file mode 100644 index 0000000..e80c20b --- /dev/null +++ b/tests/openmp-rpm/test.spec @@ -0,0 +1,34 @@ +%global toolchain clang + +Name: test +Version: 1 +Release: 1 +Summary: Test package for checking that RPM packages using -fopenmp build correctly +License: MIT + +BuildRequires: clang +BuildRequires: libomp + +Source0: test.c + +%description +clang was adding RUNPATH to binaries that use OpenMP, and since RUNPATH +is prohibited in Fedora builds, this was causing packages using clang +and OpenMP to fail to build. + +References: +https://fedoraproject.org/wiki/Changes/Broken_RPATH_will_fail_rpmbuild +https://github.com/llvm/llvm-project/commit/9b9d08111b618d74574ba03e5cc3d752ecc56f55 + +%build +clang ${CFLAGS} -fopenmp %{SOURCE0} -o main + +%check +./main + +%install +install -d %{buildroot}%{_bindir} +install main %{buildroot}%{_bindir} + +%files +%{_bindir}/main