-
Notifications
You must be signed in to change notification settings - Fork 7.2k
Add support for DragonFly #48195
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
cqundefine
wants to merge
1
commit into
microsoft:master
Choose a base branch
from
cqundefine:dragonfly_support
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+70
−1
Draft
Add support for DragonFly #48195
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| if(NOT _VCPKG_DRAGONFLY_TOOLCHAIN) | ||
| set(_VCPKG_DRAGONFLY_TOOLCHAIN 1) | ||
| if(CMAKE_HOST_SYSTEM_NAME STREQUAL "DragonFly") | ||
| set(CMAKE_CROSSCOMPILING OFF CACHE BOOL "") | ||
| endif() | ||
| set(CMAKE_SYSTEM_NAME DragonFly CACHE STRING "") | ||
|
|
||
| if(NOT DEFINED CMAKE_SYSTEM_PROCESSOR) | ||
| if(VCPKG_TARGET_ARCHITECTURE STREQUAL "x64") | ||
| set(CMAKE_SYSTEM_PROCESSOR x86_64 CACHE STRING "") | ||
| elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "x86") | ||
| set(CMAKE_SYSTEM_PROCESSOR x86 CACHE STRING "") | ||
| elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "arm64") | ||
| set(CMAKE_SYSTEM_PROCESSOR arm64 CACHE STRING "") | ||
| else() | ||
| set(CMAKE_SYSTEM_PROCESSOR "${CMAKE_HOST_SYSTEM_PROCESSOR}" CACHE STRING "") | ||
| endif() | ||
| endif() | ||
|
|
||
| if(POLICY CMP0056) | ||
| cmake_policy(SET CMP0056 NEW) | ||
| endif() | ||
| if(POLICY CMP0066) | ||
| cmake_policy(SET CMP0066 NEW) | ||
| endif() | ||
| if(POLICY CMP0067) | ||
| cmake_policy(SET CMP0067 NEW) | ||
| endif() | ||
| if(POLICY CMP0137) | ||
| cmake_policy(SET CMP0137 NEW) | ||
| endif() | ||
| list(APPEND CMAKE_TRY_COMPILE_PLATFORM_VARIABLES | ||
| VCPKG_CRT_LINKAGE VCPKG_TARGET_ARCHITECTURE | ||
| VCPKG_C_FLAGS VCPKG_CXX_FLAGS | ||
| VCPKG_C_FLAGS_DEBUG VCPKG_CXX_FLAGS_DEBUG | ||
| VCPKG_C_FLAGS_RELEASE VCPKG_CXX_FLAGS_RELEASE | ||
| VCPKG_LINKER_FLAGS VCPKG_LINKER_FLAGS_RELEASE VCPKG_LINKER_FLAGS_DEBUG | ||
| ) | ||
|
|
||
| string(APPEND CMAKE_C_FLAGS_INIT " -fPIC ${VCPKG_C_FLAGS} ") | ||
| string(APPEND CMAKE_CXX_FLAGS_INIT " -fPIC ${VCPKG_CXX_FLAGS} ") | ||
| string(APPEND CMAKE_C_FLAGS_DEBUG_INIT " ${VCPKG_C_FLAGS_DEBUG} ") | ||
| string(APPEND CMAKE_CXX_FLAGS_DEBUG_INIT " ${VCPKG_CXX_FLAGS_DEBUG} ") | ||
| string(APPEND CMAKE_C_FLAGS_RELEASE_INIT " ${VCPKG_C_FLAGS_RELEASE} ") | ||
| string(APPEND CMAKE_CXX_FLAGS_RELEASE_INIT " ${VCPKG_CXX_FLAGS_RELEASE} ") | ||
|
|
||
| string(APPEND CMAKE_MODULE_LINKER_FLAGS_INIT " ${VCPKG_LINKER_FLAGS} ") | ||
| string(APPEND CMAKE_SHARED_LINKER_FLAGS_INIT " ${VCPKG_LINKER_FLAGS} ") | ||
| string(APPEND CMAKE_EXE_LINKER_FLAGS_INIT " ${VCPKG_LINKER_FLAGS} ") | ||
| string(APPEND CMAKE_MODULE_LINKER_FLAGS_DEBUG_INIT " ${VCPKG_LINKER_FLAGS_DEBUG} ") | ||
| string(APPEND CMAKE_SHARED_LINKER_FLAGS_DEBUG_INIT " ${VCPKG_LINKER_FLAGS_DEBUG} ") | ||
| string(APPEND CMAKE_EXE_LINKER_FLAGS_DEBUG_INIT " ${VCPKG_LINKER_FLAGS_DEBUG} ") | ||
| string(APPEND CMAKE_MODULE_LINKER_FLAGS_RELEASE_INIT " ${VCPKG_LINKER_FLAGS_RELEASE} ") | ||
| string(APPEND CMAKE_SHARED_LINKER_FLAGS_RELEASE_INIT " ${VCPKG_LINKER_FLAGS_RELEASE} ") | ||
| string(APPEND CMAKE_EXE_LINKER_FLAGS_RELEASE_INIT " ${VCPKG_LINKER_FLAGS_RELEASE} ") | ||
| endif() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| set(VCPKG_TARGET_ARCHITECTURE x64) | ||
| set(VCPKG_CRT_LINKAGE dynamic) | ||
| set(VCPKG_LIBRARY_LINKAGE static) | ||
|
|
||
| set(VCPKG_CMAKE_SYSTEM_NAME DragonFly) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm pretty sure this is incorrect because it seems like it would append entries to the end?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one change is why I still have it marked as draft, the issue is some GCC versions that are in the official ports repository (including the default one if I recall correctly) set their own rpath which is needed for binaries to work. I'm not sure how to really deal with that in a different way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAIU our script tries to set a combined rpath, with
z_vcpkg_calculate_corrected_rpathconsidering the original rpath as reported by patch_elf.And there is a test port,
scripts/test_ports/vcpkg-fix-rpath.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right but as far as I can tell there's no handling for system rpaths. I noticed something similar on NetBSD where official GCC 14 sets the rpath to "/usr/pkg/gcc14/x86_64--netbsd/lib/.:/usr/pkg/gcc14/lib/." and this just gets overriden by vcpkg. This can get fixed by just setting a correct LD_LIBRARY_PATH but that's really a half fix, what should really be done?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is meant by "system rpath" in your answer?
What is the final rpath which want for a given "system rpath" and executable in the vcpkg installed tree? Give a concrete example, as if writing a test case.
What I see is that our script calls
"${PATCHELF}" --print-rpath "${elf_file}". Doesn't this include the rpath which is to be retained?If yes, then we know that it is passed as
readelf_outputtoDoesn't the output
new_rpathinclude the rpath which is to be retained?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When the rpath is set by the compiler by default (and really as a requirement) because the system libraries for the specific compiler are not in the default dynamic linker path. NetBSD and DragonFly use this when you have multiple versions of GCC installed each with their own version of libstdc++, etc.
This log shows that the rpath is read correctly, it just gets replaced entirely by vcpkg:
And once again checking with patchelf after the install:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current default behavior is to only keep entries with
$ORIGIN.There is an
X_VCPKG_RPATH_KEEP_SYSTEM_PATHSvariable to keep all entries - you could set in the triplet file.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Yes, it will keep all entries, including those set by the port. I'm not sure this is the solution. The alternative is to provide/detect what the compiler sets in a controlled way, and put this on a positive list.)