This is an archive of the discontinued LLVM Phabricator instance.

[clang-cl] Always interpret the LIB env var as separated with semicolons
ClosedPublic

Authored by mstorsjo on Sep 21 2020, 12:24 AM.

Details

Summary

When cross compiling with clang-cl, clang splits the INCLUDE env variable around semicolons (clang/lib/Driver/ToolChains/MSVC.cpp, MSVCToolChain::AddClangSystemIncludeArgs) and lld splits the LIB variable similarly (lld/COFF/Driver.cpp, LinkerDriver::addLibSearchPaths). Therefore, the consensus for cross compilation with clang-cl and lld-link seems to be to use semicolons, despite path lists normally being separated by colons on unix and EnvPathSeparator being set to that.

Therefore, handle the LIB variable similarly in Clang, when handling lib file arguments when driving linking via Clang.

This fixes commands like "clang-cl test.c -Fetest.exe kernel32.lib" in a cross compilation setting. Normally, most users call (lld-)link directly, but meson happens to use this command syntax for has_function() tests.

Diff Detail

Event Timeline

mstorsjo created this revision.Sep 21 2020, 12:24 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptSep 21 2020, 12:24 AM
mstorsjo requested review of this revision.Sep 21 2020, 12:24 AM
rnk accepted this revision.Sep 21 2020, 8:58 AM

lgtm

This revision is now accepted and ready to land.Sep 21 2020, 8:58 AM
This revision was landed with ongoing or failed builds.Sep 21 2020, 1:43 PM
This revision was automatically updated to reflect the committed changes.