Don't create empty elements in include path vars#17970
Don't create empty elements in include path vars#17970ras0219-msft merged 1 commit intomicrosoft:masterfrom
Conversation
BackgroundI got reproducible failures when I tried to build gettext[tools] on osx with port libxml2 installed. The error pointed to vcpkg's libxml2 where I would have expected to find usage of gettext's embedded libxml2. From running: (no reference to vcpkg!) the errors were like: I looked into vcpkg_configure_cmake and found: Note that this creates values like: ... including the trailing Now clang detects duplicate ... and leaves it only after all explicit entries and the vcpkg include dir. So that is why |
|
Yes this PR fixes #17892. I have tested it locally. 👍 |
|
x64_osx libmicrohttpd: unrelated, #17653. |
More backgroundclang documentation says that "Empty components in the environment variable are ignored." But this is not true, as can be verified by experimentation and source code inspection.
Reproducer: mkdir /tmp/MARK-I-OPTION
mkdir /tmp/MARK-ENV-VAR
echo | C_INCLUDE_PATH=/tmp/MARK-ENV-VAR clang -E -Wp,-v - -o /dev/null -I. -I/tmp/MARK-I-OPTION 2> c_include_path-no-colon
echo | C_INCLUDE_PATH=/tmp/MARK-ENV-VAR: clang -E -Wp,-v - -o /dev/null -I. -I/tmp/MARK-I-OPTION 2> c_include_path-with-colon
diff -U20 c_include_path-no-colon c_include_path-with-colon
echo | CPATH=/tmp/MARK-ENV-VAR clang -E -Wp,-v - -o /dev/null -I. -I/tmp/MARK-I-OPTION 2> cpath-no-colon
echo | CPATH=/tmp/MARK-ENV-VAR: clang -E -Wp,-v - -o /dev/null -I. -I/tmp/MARK-I-OPTION 2> cpath-with-colon
diff -U20 cpath-no-colon cpath-with-colonOutput for C_INCLUDE_PATH (somewhat older clang on Linux): --- c_include_path-no-colon 2021-05-18 19:23:22.718867910 +0200
+++ c_include_path-with-colon 2021-05-18 19:59:06.197846524 +0200
@@ -1,12 +1,14 @@
clang -cc1 version 8.0.0 based upon LLVM 8.0.0 default target x86_64-pc-linux-gnu
ignoring nonexistent directory "/include"
+ignoring duplicate directory "."
+ as it is a non-system directory that duplicates a system directory
#include "..." search starts here:
#include <...> search starts here:
- .
/tmp/MARK-I-OPTION
/tmp/MARK-ENV-VAR
+ .
/usr/local/include
/usr/lib/llvm-8/lib/clang/8.0.0/include
/usr/include/x86_64-linux-gnu
/usr/include
End of search list.Output for CPATH: --- cpath-no-colon 2021-05-18 19:23:53.654933769 +0200
+++ cpath-with-colon 2021-05-18 19:24:00.914949225 +0200
@@ -1,12 +1,13 @@
clang -cc1 version 8.0.0 based upon LLVM 8.0.0 default target x86_64-pc-linux-gnu
ignoring nonexistent directory "/include"
+ignoring duplicate directory "."
#include "..." search starts here:
#include <...> search starts here:
.
/tmp/MARK-I-OPTION
/tmp/MARK-ENV-VAR
/usr/local/include
/usr/lib/llvm-8/lib/clang/8.0.0/include
/usr/include/x86_64-linux-gnu
/usr/includeReported as https://bugs.llvm.org/show_bug.cgi?id=50398 |
I think we should wait for #16478. |
|
gcc (tested: 7.5) behaves the same. Details |
|
This changes also fixes building gettext[tools] on Linux. |
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
Ping @Neumann-A for review this PR. |
|
This LGTM, thanks for the fix! |
What does your PR fix?
This PR fixes a reproducible build error for
gettext[tools]:x64-osxwhenlibxml2was already installed. It may fix a number of similar build quirks withvcpkg_configure_make.Which triplets are supported/not supported? Have you updated the CI baseline?
all (tested on osx), no
Does your PR follow the maintainer guide?
yes
If you have added/updated a port: Have you run
./vcpkg x-add-version --alland committed the result?-/-