summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2017-07-04 00:56:38 +0200
committerGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2017-07-07 16:23:46 +0000
commit353fb118c3d92bac2bfdd88922320d0d3e8563c2 (patch)
treedf828708a0ccb0ed3c07fdd87f18a69cc8f5b132
parentf2db946fa4d660d4e4fbddb777a8ef7df05d2282 (diff)
Fix detection of QMAKE_DEFAULT_LIBDIRS with Clang under Linux
With 4183475080d334d7d17d02e6ad4eb53c01205c54, Qt fails to build if qmake is unable to detect the compiler's default include and library search paths. Clang on non-Darwin systems was missing working code for the detection. Unlike GCC, Clang on its own does not print the library search paths when called with the -v option. On Darwin, the -Wl,-v option will reach ld64, which will print those paths. However, neither GNU ld nor gold will print anything useful with just -v. GNU ld has a --verbose option that does print some search paths, but those are not the ones used when ld is invoked (via collect2) by GCC or Clang, so it can't be used. To make Clang print its library search paths one can use -print-search-dirs, which however doesn't print include search paths. So amend the existing code in order to make a second call to clang on non-Darwin systems. This second call is used for library path detection, and fixes the build on non-Darwin (tested on Linux). Change-Id: Ic858f908ee1a2e0eb307abb074daee0ded38abd5 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
-rw-r--r--mkspecs/features/toolchain.prf20
1 files changed, 20 insertions, 0 deletions
diff --git a/mkspecs/features/toolchain.prf b/mkspecs/features/toolchain.prf
index eb7b1385f2..b3726a1160 100644
--- a/mkspecs/features/toolchain.prf
+++ b/mkspecs/features/toolchain.prf
@@ -111,6 +111,26 @@ isEmpty($${target_prefix}.INCDIRS) {
}
}
}
+ !darwin:clang {
+ # Clang on a non-Apple system (that is, a system without ld64 -- say, with GNU ld
+ # or gold under Linux) will not print any library search path. Need to use another
+ # invocation with different options (which in turn doesn't print include search
+ # paths, so it can't just be used in place of the above code).
+ # What's more, -print-search-dirs can't be used on clang on Apple because it
+ # won't print all the library paths (only the clang-internal ones).
+ output = $$system("$$cmd_prefix $$QMAKE_CXX -print-search-dirs", lines, ec)
+ !equals(ec, 0): \
+ error("Cannot run compiler '$$QMAKE_CXX'. Maybe you forgot to setup the environment?")
+
+ for (line, output) {
+ contains(line, "^libraries: .*") {
+ line ~= s,^libraries: ,,
+ paths = $$split(line, $$QMAKE_DIRLIST_SEP)
+ for (path, paths): \
+ QMAKE_DEFAULT_LIBDIRS += $$clean_path($$replace(path, ^=, $$[SYSROOT]))
+ }
+ }
+ }
isEmpty(QMAKE_DEFAULT_LIBDIRS)|isEmpty(QMAKE_DEFAULT_INCDIRS): \
!integrity: \
error("failed to parse default search paths from compiler output")