]> git.tdb.fi Git - builder.git/commitdiff
Gather more system path information for GnuLinker
authorMikko Rasa <tdb@tdb.fi>
Tue, 27 Dec 2022 15:58:08 +0000 (17:58 +0200)
committerMikko Rasa <tdb@tdb.fi>
Tue, 27 Dec 2022 15:58:08 +0000 (17:58 +0200)
source/gnulinker.cpp

index 19313336473a2ac92b6f26e80e05824f94371347..591c80be20db9aefc4d7b7d9713c455313e14665 100644 (file)
@@ -1,5 +1,6 @@
 #include <stdexcept>
 #include <vector>
+#include <msp/core/algorithm.h>
 #include <msp/fs/dir.h>
 #include <msp/fs/utils.h>
 #include <msp/strings/format.h>
@@ -109,6 +110,7 @@ void GnuLinker::do_prepare(ToolData &tool) const
        {
                ExternalTask::Arguments argv;
                argv.push_back(exe->get_path().str());
+               argv.push_back("-v");
                argv.push_back("-Wl,--verbose");
                argv.push_back("-nostdlib");
                if(!sysroot.empty())
@@ -118,6 +120,23 @@ void GnuLinker::do_prepare(ToolData &tool) const
                try
                {
                        string output = ExternalTask::run_and_capture_output(argv, FS::Path(), true);
+
+                       string::size_type lib_path = output.find("LIBRARY_PATH=");
+                       if(lib_path!=string::npos)
+                       {
+                               string::size_type newline = output.find('\n', lib_path);
+                               for(const string &p: split(output.substr(lib_path+13, newline-lib_path-13), ':'))
+                               {
+                                       FS::Path path = strip(p);
+                                       if(!any_equals(tool.system_path, path))
+                                       {
+                                               builder.get_logger().log("tools", "Got %s frontend system path: %s", tool_tag, path);
+                                               tool.system_path.push_back(path);
+                                       }
+                                       path_found = true;
+                               }
+                       }
+
                        string::size_type start = 0;
                        while(start<output.size())
                        {
@@ -141,8 +160,11 @@ void GnuLinker::do_prepare(ToolData &tool) const
                                }
 
                                path /= output.substr(search_dir, end-search_dir);
-                               builder.get_logger().log("tools", "Got %s system path: %s", tool_tag, path);
-                               tool.system_path.push_back(path);
+                               if(!any_equals(tool.system_path, path))
+                               {
+                                       builder.get_logger().log("tools", "Got %s implicit system path: %s", tool_tag, path);
+                                       tool.system_path.push_back(path);
+                               }
                                path_found = true;
 
                                start = end+3;