llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
29.03k stars 11.96k forks source link

LLVM still and will not support for static link openmp? #59101

Closed TaoTao-real closed 1 year ago

TaoTao-real commented 1 year ago

every one.

I am curious about did clang can't static link the openmp library when compliling. When i try to build spec2017 intspeed benchmarks, I found when i try to build them staticly, will failed with error cannot find -lomp.

  /usr/lib/llvm-10/bin/clang -m64  -z muldefs     -pthread -static    -DSPEC_LINUX_X64   -DSPEC_OPENMP -fopenmp -Wno  -return-type -DUSE_OPENMP -I /usr/lib/lib/libomp_oss/exports/common/include  av.o caretx.o deb.o doio.o doop.o dum  p.o globals.o gv.o hv.o keywords.o locale.o mg.o numeric.o op.o pad.o perl.o perlapi.o perlio.o perlmain.o perly.o   pp.o pp_ctl.o pp_hot.o pp_pack.o pp_sort.o pp_sys.o regcomp.o regexec.o run.o scope.o sv.o taint.o toke.o univers  al.o utf8.o util.o reentr.o mro_core.o mathoms.o specrand/specrand.o dist/PathTools/Cwd.o dist/Data-Dumper/Dumper.  o ext/Devel-Peek/Peek.o cpan/Digest-MD5/MD5.o cpan/Digest-SHA/SHA.o DynaLoader.o dist/IO/IO.o dist/IO/poll.o cpan/  MIME-Base64/Base64.o Opcode.o dist/Storable/Storable.o ext/Sys-Hostname/Hostname.o cpan/Time-HiRes/HiRes.o ext/XS-  Typemap/stdio.o ext/attributes/attributes.o cpan/HTML-Parser/Parser.o ext/mro/mro.o ext/re/re.o ext/re/re_comp.o e  xt/re/re_exec.o ext/arybase/arybase.o ext/PerlIO-scalar/scalar.o ext/PerlIO-via/via.o ext/File-Glob/bsd_glob.o ext  /File-Glob/Glob.o ext/Hash-Util/Util.o ext/Hash-Util-FieldHash/FieldHash.o ext/Tie-Hash-NamedCapture/NamedCapture.  o cpan/Scalar-List-Utils/ListUtil.o             -lm     -fopenmp -L/usr/lib/lib/libomp_oss/exports/lin_32e/lib      -o perlbench_s
  /usr/local/bin/ld: cannot find -lomp

So, i searched the llvm lib for omp, only find libomp.so, but no omp realated .a file. Then found the posted mail of wheather need static openmp library, seem like LLVM developers reject this opinion. https://lists.llvm.org/pipermail/openmp-dev/2016-January/001051.html

Did i miss something, or is there someway can link openmp staticly i not found?

Thanks for your suggestions.

I did build those spec benchmarks use llvm10 and llvm15 with dynamic link on ubuntu20.04, all found the -lomp, build successfully.

llvmbot commented 1 year ago

@llvm/issue-subscribers-openmp

jdoerfert commented 1 year ago

I thought the host runtime (libomp) can be build as static and dynamic library. Linking it in statically was supported at some point but might cause problems down the line. That said, if there is no option to build a static library I doubt we have much incentive to add one.

shiltian commented 1 year ago

JFYI, https://discourse.llvm.org/c/runtimes/openmp/ is a better place for OpenMP related questions. I'll close this one for now. Feel free to open it if you see necessary.