[all-commits] [llvm/llvm-project] b8000c: [Windows] Autolink with basenames and add libdir t...

Reid Kleckner via All-commits all-commits at lists.llvm.org
Tue Apr 28 11:36:41 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: b8000c0ce84541c5b5535419234fb65ce77d6756
      https://github.com/llvm/llvm-project/commit/b8000c0ce84541c5b5535419234fb65ce77d6756
  Author: Reid Kleckner <rnk at google.com>
  Date:   2020-04-28 (Tue, 28 Apr 2020)

  Changed paths:
    M clang/docs/ReleaseNotes.rst
    M clang/docs/UsersManual.rst
    M clang/include/clang/Driver/ToolChain.h
    M clang/lib/Driver/SanitizerArgs.cpp
    M clang/lib/Driver/ToolChain.cpp
    M clang/lib/Driver/ToolChains/Clang.cpp
    M clang/lib/Driver/ToolChains/MSVC.cpp
    M clang/test/Driver/cl-options.c
    M clang/test/Driver/sanitizer-ld.c
    M llvm/cmake/modules/HandleLLVMOptions.cmake

  Log Message:
  -----------
  [Windows] Autolink with basenames and add libdir to libpath

Prior to this change, for a few compiler-rt libraries such as ubsan and
the profile library, Clang would embed "-defaultlib:path/to/rt-arch.lib"
into the .drective section of every object compiled with
-finstr-profile-generate or -fsanitize=ubsan as appropriate.

These paths assume that the link step will run from the same working
directory as the compile step. There is also evidence that sometimes the
paths become absolute, such as when clang is run from a different drive
letter from the current working directory. This is fragile, and I'd like
to get away from having paths embedded in the object if possible. Long
ago it was suggested that we use this for ASan, and apparently I felt
the same way back then:
https://reviews.llvm.org/D4428#56536

This is also consistent with how all other autolinking usage works for
PS4, Mac, and Windows: they all use basenames, not paths.

To keep things working for people using the standard GCC driver
workflow, the driver now adds the resource directory to the linker
library search path when it calls the linker. This is enough to make
check-ubsan pass, and seems like a generally good thing.

Users that invoke the linker directly (most clang-cl users) will have to
add clang's resource library directory to their linker search path in
their build system. I'm not sure where I can document this. Ideally I'd
also do it in the MSBuild files, but I can't figure out where they go.
I'd like to start with this for now.

Reviewed By: hans

Differential Revision: https://reviews.llvm.org/D65543




More information about the All-commits mailing list