aomp icon indicating copy to clipboard operation
aomp copied to clipboard

linker error

Open ye-luo opened this issue 5 years ago • 7 comments

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)

ye-luo avatar Mar 31 '20 13:03 ye-luo

Thanks for reporting this issue. I will look into it and report back.

estewart08 avatar Apr 01 '20 01:04 estewart08

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.

gregrodgers avatar Apr 10 '20 20:04 gregrodgers

Please also double check if mylib.a is presented twice on the link line, the linking can still succeed.

ye-luo avatar Apr 10 '20 21:04 ye-luo

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 avatar Apr 10 '20 23:04 gregrodgers

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

ye-luo avatar Apr 10 '20 23:04 ye-luo

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 avatar Apr 24 '20 16:04 jsjodin

@jsjodin appreciated if you could remove the restriction.

ye-luo avatar Apr 24 '20 22:04 ye-luo

Resolved long time ago.

ye-luo avatar Apr 28 '23 15:04 ye-luo