[vcpkg] Add -isysroot args to CPPFLAGS#25201
[vcpkg] Add -isysroot args to CPPFLAGS#25201m-kuhn wants to merge 2 commits intomicrosoft:masterfrom
Conversation
So preprocessor only configure tests get the right includes
0c0f17d to
4b2916b
Compare
| set(C_FLAGS "${VCPKG_DETECTED_CMAKE_C_FLAGS_${flag_suffix}}") | ||
| separate_arguments(C_FLAGS) | ||
| list(FIND C_FLAGS "-isysroot" ISYSROOT_FLAG_POS) |
There was a problem hiding this comment.
Why not use if ("${VCPKG_DETECTED_CMAKE_C_FLAGS_${flag_suffix}}" MATCHES "-isysroot")?
Are there other similar options?
There was a problem hiding this comment.
${VCPKG_DETECTED_CMAKE_C_FLAGS_${flag_suffix}} is a string with all flags, separate_arguments splits it into a list and this line finds the index in this list to extract just this argument, so we can use it. I don't see how MATCHES could replace this logic.
Am I missing the point?
There was a problem hiding this comment.
I think the irritating point is that one part of flag processing is done with regex on the string, and one part of flag processing is (now) done on a list.
There was a problem hiding this comment.
The regex approach will likely run into limitations if the path contains spaces
| MATH(EXPR ISYSROOT_FLAG_POS "${ISYSROOT_FLAG_POS}+1") | ||
| list(SUBLIST C_FLAGS ${ISYSROOT_FLAG_POS} 1 ISYSROOT) | ||
| set(CPPFLAGS_${flag_suffix} "${CPPFLAGS_${flag_suffix}} -isysroot ${ISYSROOT}") | ||
| string(REGEX REPLACE "-isysroot ${ISYSROOT}" "" CFLAGS_${flag_suffix} "${VCPKG_DETECTED_CMAKE_C_FLAGS_${flag_suffix}}") |
There was a problem hiding this comment.
@Neumann-A removing this from CFLAGS / CXXFLAGS breaks the build
There was a problem hiding this comment.
?
Why and where?
It should always be $(CPPFLAGS) $(CFLAGS) in the makefiles.
There was a problem hiding this comment.
From gettext-runtime/configure in checking whether <wchar.h> uses 'inline' correctly:
if $CC -o conftest$ac_exeext $CFLAGS $LDFLAGS conftest1.$ac_objext conftest2.$ac_objext $LIBS >&5 2>&1; then
Shouldn't the toolchain be making sure any such SDK folder is available rather than having each build system under the sun try to fix it up like this? |
In vcpkg, "each build system under the sun" should take the details from CMake. Taking from CMake is done here: vcpkg/scripts/get_cmake_vars/CMakeLists.txt Lines 101 to 114 in 8e1f46d Should it be taken differently, before transforming it for a particular build system such as autotools? |
It seems like this should mean |
it is the problem is that a pure preprocessor run does not have the flag. |
Shouldn't a pure preprocessor run have all flags though? This is far from the only compiler switch that may affect preprocessor results. |
Well, there is no |
Nope due to differences in C and CXX flags. Some CXX flags are not allowed in C so there needs to be some filtering. I opted only for The question here is rather why does it only do you preprocessor check and no compile check. Maybe availability of includes is only checked with the preprocessor? |
Availability of certain contents of includes in this case, FWIW. # checking for uid_t in sys/types.h
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <sys/types.h>
_ACEOF
if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
$EGREP "uid_t" >/dev/null 2>&1; then :
ac_cv_type_uid_t=yes
else
ac_cv_type_uid_t=no
fiBut I'm not sure what this knowledge changes, properly populating |
Adding something like |
|
@JackBoosY is the answer good enough to remove author-response? |
|
Ping @BillyONeal @dg0yt @Neumann-A for review agian. |
It doesn't look like this is setting a pure preprocessor variable though, it's setting CPPFLAGS.
I'm confused, why is that not VCPKG_DETECTED_CXX_FLAGS as already set here? 4b2916b#diff-b92b07d5c0c681687d71463c6a368fae98e9ffedb241e2aadbde3aac688899a9R93 |
|
Sorry if I'm stating something obvious, just to avoid a potential source of confusion: CFLAGS: C Compiler Flags My understanding: Currently this is being completely ignored and things work because on osx |
|
Ah, CPP as in C PreProcessor, not C PlusPlus. No, that was not obvious to me. :) My "coming from a platform where the preprocessor is not a separate program" is showing. |
|
#25670 implements the same approach as for meson, discarding this approach until the other (osx specific approach) runs into limitations |
So preprocessor only configure tests get the right includes
Describe the pull request
What does your PR fix?
CPPFLAGSare currently lacking-isysrootwhen invoking autoconf tools. This leads to preprocessor only tests missing headers and producing bogus configuration results. This is an issue on macos where system headers do not live in the system root but rather a dedicated sdk folder.For more information see https://github.com/microsoft/vcpkg/pull/21847/files#r776056939
Which triplets are supported/not supported? Have you updated the CI baseline?
all
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?No port touched