This is an archive of the discontinued LLVM Phabricator instance.

[OPENMP] Link libomp.lib on Windows
ClosedPublic

Authored by ABataev on Aug 11 2015, 3:07 AM.

Details

Summary

Adds libomp.lib for -fopenmp=libomp and libiomp5md.lib for -fopenmp=libiomp5 on Windows

Diff Detail

Repository
rL LLVM

Event Timeline

ABataev updated this revision to Diff 31780.Aug 11 2015, 3:07 AM
ABataev retitled this revision from to [OPENMP] Link libomp.lib on Windows.
ABataev updated this object.
ABataev added reviewers: chandlerc, rsmith.
ABataev added a subscriber: cfe-commits.
ABataev added a subscriber: ismail.Aug 11 2015, 3:27 AM

OpenMP/linking.c fails here with VS2015 (building with -DCLANG_DEFAULT_OPENMP_RUNTIME=libomp)

Command 21 Stderr:
C:\cygwin64\home\ismail\src\llvm\tools\clang\test\OpenMP\linking.c:75:24: error: expected string not found in input
// CHECK-MSVC-LINK-64: "link.exe"

^

<stdin>:1:1: note: scanning from here
clang version 3.8.0 (http://llvm.org/git/clang d7efa4b285d2464f1844b52b220381c64cd64bf6) (http://llvm.org/git/llvm bee32461e9d
466ed85439a026c62cb896b638653)
^
<stdin>:6:73: note: possible intended match here
"C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\amd64\\link.exe" "-out:C:\\cygwin64\\home\\ismail\\src\\llvm
\\dist\\tools\\clang\\test\\OpenMP\\Output\\linking.c.tmp.o" "-defaultlib:libcmt" "-libpath:C:\\Program Files (x86)\\Microsoft
Visual Studio 14.0\\VC\\lib\\amd64" "-libpath:C:\\Program Files (x86)\\Windows Kits\\8.1\\Lib\\winv6.3\\um\\x64" "-nologo" "-
nodefaultlib:vcomp.lib" "-nodefaultlib:vcompd.lib" "-defaultlib:libomp.lib" "C:\\cygwin64\\tmp\\linking-19e90e.o"

^
ABataev updated this revision to Diff 31792.Aug 11 2015, 4:34 AM

Test fix

Tests pass but, now when I tried to compile a file with -fopenmp I get:

LINK: fatal error LNK1104: cannot open file 'libomp.lib'

libomp.lib does exist in "C:\Program Files\LLVM\lib" but I guess we need to pass the library path down to linker.

Tests pass but, now when I tried to compile a file with -fopenmp I get:

LINK: fatal error LNK1104: cannot open file 'libomp.lib'

libomp.lib does exist in "C:\Program Files\LLVM\lib" but I guess we need to pass the library path down to linker.

What library path should be passed (where did you build the OpenMP runtime library)?

What library path should be passed (where did you build the OpenMP runtime library)?

This is a default installation so the lib path is $PATH_TO_CLANG_EXE/../lib which in my case is C:\Program Files\LLVM\lib

ABataev updated this revision to Diff 32275.Aug 17 2015, 2:11 AM

Add path to libomp.lib.

ismail accepted this revision.Aug 17 2015, 5:19 AM
ismail added a reviewer: ismail.

Great work. Tested fine on Windows. Next step would be mapping /openmp flag to -fopenmp but I guess thats for another bug.

This revision is now accepted and ready to land.Aug 17 2015, 5:19 AM
ABataev added a reviewer: rnk.Aug 18 2015, 1:40 AM
rnk accepted this revision.Aug 18 2015, 11:30 AM
rnk edited edge metadata.

lgtm

This revision was automatically updated to reflect the committed changes.