[PATCH] D75373: [Clang] Fix Hurd toolchain class hierarchy
Alexandre Ganea via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Feb 28 11:12:18 PST 2020
aganea created this revision.
aganea added reviewers: hans, sthibaul, kristina.
Herald added subscribers: cfe-commits, dexonsmith, Prazek.
Herald added a project: clang.
aganea added a comment.
@hans, do you think this could be included in 10.0?
As noted in PR45061, a two-stage ThinLTO build fails the `clang/test/Driver/hurd.c` test because of a `static_cast` here <https://github.com/llvm/llvm-project/blob/master/clang/lib/Driver/ToolChains/Gnu.cpp#L350> which wrongly converts an instance of `clang::driver::toolchains::Hurd` into that of `clang::driver::toolchains::Linux`. ThinLTO will later devirtualize the `ToolChain.getDynamicLinker(Args);` call and use `Linux::getDynamicLinker()` instead, causing the test to generate a wrong `-dynamic-linker` linker flag (`/lib/ld-linux.so.2` instead of `/lib/ld.so`)
This patch simply fixes the `Hurd` class hierarchy as (I think) it was intended to be.
Ideally, and because of the `static_cast` mentioned above, maybe `gnutools::Linker` should take a `const Linux &` instance, not a `const ToolChain &`. But that causes other issues and could be done later.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D75373
Files:
clang/lib/Driver/ToolChains/Hurd.cpp
clang/lib/Driver/ToolChains/Hurd.h
Index: clang/lib/Driver/ToolChains/Hurd.h
===================================================================
--- clang/lib/Driver/ToolChains/Hurd.h
+++ clang/lib/Driver/ToolChains/Hurd.h
@@ -10,13 +10,14 @@
#define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_Hurd_H
#include "Gnu.h"
+#include "Linux.h"
#include "clang/Driver/ToolChain.h"
namespace clang {
namespace driver {
namespace toolchains {
-class LLVM_LIBRARY_VISIBILITY Hurd : public Generic_ELF {
+class LLVM_LIBRARY_VISIBILITY Hurd : public Linux {
public:
Hurd(const Driver &D, const llvm::Triple &Triple,
const llvm::opt::ArgList &Args);
@@ -27,9 +28,9 @@
AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
llvm::opt::ArgStringList &CC1Args) const override;
- virtual std::string computeSysRoot() const;
+ std::string computeSysRoot() const override;
- virtual std::string getDynamicLinker(const llvm::opt::ArgList &Args) const;
+ std::string getDynamicLinker(const llvm::opt::ArgList &Args) const override;
std::vector<std::string> ExtraOpts;
Index: clang/lib/Driver/ToolChains/Hurd.cpp
===================================================================
--- clang/lib/Driver/ToolChains/Hurd.cpp
+++ clang/lib/Driver/ToolChains/Hurd.cpp
@@ -63,7 +63,7 @@
Hurd::Hurd(const Driver &D, const llvm::Triple &Triple,
const ArgList &Args)
- : Generic_ELF(D, Triple, Args) {
+ : Linux(D, Triple, Args) {
std::string SysRoot = computeSysRoot();
path_list &Paths = getFilePaths();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D75373.247315.patch
Type: text/x-patch
Size: 1539 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200228/390c51a7/attachment.bin>
More information about the cfe-commits
mailing list