linker error
Using 0.7-7. The AOMP linker works on more complicated miniQMC but failed in linking the following test case. https://github.com/ye-luo/openmp-target/tree/master/hands-on/tests/link_static_fat_bin
/usr/lib/aomp/bin/clang++ -Xopenmp-target=amdgcn-amd-amdhsa -march=gfx906 -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa -c classA.cpp
rm -f mylib.a
ar qc mylib.a classA.o
ranlib mylib.a
/usr/lib/aomp/bin/clang++ -Xopenmp-target=amdgcn-amd-amdhsa -march=gfx906 -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa -c main.cpp
/usr/lib/aomp/bin/clang++ -Xopenmp-target=amdgcn-amd-amdhsa -march=gfx906 -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa main.o ./mylib.a
error
: error loading '/tmp/mylib-gfx906-fd6e48.a': The file was not recognized as a valid object file!: The file was not recognized as a valid object file.
clang-9: error: amdgcn-link command failed with exit code 1 (use -v to see invocation)
Thanks for reporting this issue. I will look into it and report back.
Jan, this looks like we need to run unbundle-archive utility on any .a on the command line and feed the extracted device-specific archive to the gpu link phase. I hope we can get this in the next release of AOMP 11.5-0.
Please also double check if mylib.a is presented twice on the link line, the linking can still succeed.
Ye-luo, this would work if you named the archive libmylib.a and you put the following on the command line -L$PWD -lmylib. aomp support heterogeneous archives using -l and -L. However, we had a small oversight and do not pick up heterogenous archives from the command line. I would rather fix the original problem than have you circumvent this.
@gregrodgers Thank you. Fixing the original problem is appreciated. Both use cases are valid.
Please also double check if mylib.a is presented twice on the link line, the linking can still succeed.
This is a actually a separate issue. In another working case, if I present the static library (.a) twice, aomp failed to link with multi definition error.
The reason this fails and miniQMC works is that the archive file mylib.a file name does not start with "lib", if you name the file "libmylib.a" it works. We can remove this restriction.
@jsjodin appreciated if you could remove the restriction.
Resolved long time ago.