[pkg-d-commits] [ldc] 59/74: Incorporate LTO stuff in GCC ArgsBuilder

Matthias Klumpp mak at moszumanska.debian.org
Thu Jul 13 20:54:19 UTC 2017


This is an automated email from the git hooks/post-receive script.

mak pushed a commit to annotated tag v1.3.0-beta2
in repository ldc.

commit 1339c02598d349f138cc6bf1deec7369ad05e870
Author: Martin <noone at nowhere.com>
Date:   Sat May 27 02:42:07 2017 +0200

    Incorporate LTO stuff in GCC ArgsBuilder
---
 driver/linker-gcc.cpp | 57 +++++++++++++++++++++++++++------------------------
 1 file changed, 30 insertions(+), 27 deletions(-)

diff --git a/driver/linker-gcc.cpp b/driver/linker-gcc.cpp
index c89b307..01db7fb 100644
--- a/driver/linker-gcc.cpp
+++ b/driver/linker-gcc.cpp
@@ -28,11 +28,33 @@ static llvm::cl::opt<std::string>
                llvm::cl::value_desc("file"));
 
 //////////////////////////////////////////////////////////////////////////////
-// LTO functionality
+
+namespace {
+
+class ArgsBuilder {
+public:
+  std::vector<std::string> args;
+
+  void build(llvm::StringRef outputPath,
+             llvm::cl::boolOrDefault fullyStaticFlag);
+
+private:
+  void addSanitizers();
+  void addUserSwitches();
+  void addDefaultLibs();
+  void addArch();
 
 #if LDC_LLVM_VER >= 309
+  void addLTOGoldPluginFlags();
+  void addDarwinLTOFlags();
+  void addLTOLinkFlags();
+#endif
+};
 
-namespace {
+//////////////////////////////////////////////////////////////////////////////
+// LTO functionality
+
+#if LDC_LLVM_VER >= 309
 
 void addLinkerFlag(std::vector<std::string> &args, const llvm::Twine &flag) {
   args.push_back("-Xlinker");
@@ -75,7 +97,7 @@ std::string getLTOGoldPluginPath() {
   }
 }
 
-void addLTOGoldPluginFlags(std::vector<std::string> &args) {
+void ArgsBuilder::addLTOGoldPluginFlags() {
   addLinkerFlag(args, "-plugin");
   addLinkerFlag(args, getLTOGoldPluginPath());
 
@@ -118,7 +140,7 @@ std::string getLTOdylibPath() {
   }
 }
 
-void addDarwinLTOFlags(std::vector<std::string> &args) {
+void ArgsBuilder::addDarwinLTOFlags() {
   std::string dylibPath = getLTOdylibPath();
   if (!dylibPath.empty()) {
     args.push_back("-lto_library");
@@ -127,42 +149,23 @@ void addDarwinLTOFlags(std::vector<std::string> &args) {
 }
 
 /// Adds the required linker flags for LTO builds to args.
-void addLTOLinkFlags(std::vector<std::string> &args) {
+void ArgsBuilder::addLTOLinkFlags() {
   if (global.params.targetTriple->isOSLinux() ||
       global.params.targetTriple->isOSFreeBSD() ||
       global.params.targetTriple->isOSNetBSD() ||
       global.params.targetTriple->isOSOpenBSD() ||
       global.params.targetTriple->isOSDragonFly()) {
     // Assume that ld.gold or ld.bfd is used with plugin support.
-    addLTOGoldPluginFlags(args);
+    addLTOGoldPluginFlags();
   } else if (global.params.targetTriple->isOSDarwin()) {
-    addDarwinLTOFlags(args);
+    addDarwinLTOFlags();
   }
 }
-} // anonymous namespace
 
 #endif // LDC_LLVM_VER >= 309
 
 //////////////////////////////////////////////////////////////////////////////
 
-namespace {
-
-class ArgsBuilder {
-public:
-  std::vector<std::string> args;
-
-  void build(llvm::StringRef outputPath,
-             llvm::cl::boolOrDefault fullyStaticFlag);
-
-private:
-  void addSanitizers();
-  void addUserSwitches();
-  void addDefaultLibs();
-  void addArch();
-};
-
-//////////////////////////////////////////////////////////////////////////////
-
 void ArgsBuilder::build(llvm::StringRef outputPath,
                         llvm::cl::boolOrDefault fullyStaticFlag) {
   // object files
@@ -205,7 +208,7 @@ void ArgsBuilder::build(llvm::StringRef outputPath,
   // Add LTO link flags before adding the user link switches, such that the user
   // can pass additional options to the LTO plugin.
   if (opts::isUsingLTO())
-    addLTOLinkFlags(args);
+    addLTOLinkFlags();
 #endif
 
   addUserSwitches();

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-d/ldc.git



More information about the pkg-d-commits mailing list