Fix Subprocess.cpp with clang + _FORTIFY_SOURCE on glibc >= 2.40#2519
Open
mszabo-wikia wants to merge 1 commit intofacebook:mainfrom
Open
Fix Subprocess.cpp with clang + _FORTIFY_SOURCE on glibc >= 2.40#2519mszabo-wikia wants to merge 1 commit intofacebook:mainfrom
mszabo-wikia wants to merge 1 commit intofacebook:mainfrom
Conversation
On glibc >= 2.40, _FORTIFY_SOURCE overloads openat() when building with clang, causing the `decltype` call in Subprocess.cpp to fail since the target becomes ambiguous. So, explicitly specify our overload of choice in this case. Reproduce/test by setting `CMAKE_CXX_FLAGS=-D_FORTIFY_SOURCE=3 -DCMAKE_CXX_COMPILER=clang++`.
mszabo-wikia
added a commit
to mszabo-wikia/hhvm
that referenced
this pull request
Nov 18, 2025
Update and extend the list of hardening-related compiler flags used by HHVM to better represent modern distro defaults. * Convert the existing `ENABLE_SSP` build option into a new `ENABLE_HARDENING` option and put an updated list of security flags behind it. Both clang and GCC have been supporting these options for a while now, so we can set them irrespective of the compiler. * Put PIE-related options behind a separate `ENABLE_PIE` build option so that we can produce and compare non-PIE and PIE builds once we fix compatibility with PIE. * Forward `CMAKE_BUILD_TYPE` to vendored subprojects. Lack of this was causing the projects to be built without compiler optimizations, which doesn't play well with `FORTIFY_SOURCE`. On systems with glibc >= 2.40, facebook/folly#2519 is needed for this option to work. The overhead from these flags is likely to be limited, as many of them have been set by default for distribution packages for several years now.[1] [1] https://github.com/jvoisin/compiler-flags-distro
mszabo-wikia
added a commit
to mszabo-wikia/hhvm
that referenced
this pull request
Nov 24, 2025
Update and extend the list of hardening-related compiler flags used by HHVM to better represent modern distro defaults. * Convert the existing `ENABLE_SSP` build option into a new `ENABLE_HARDENING` option and put an updated list of security flags behind it. Both clang and GCC have been supporting these options for a while now, so we can set them irrespective of the compiler. * Put PIE-related options behind a separate `ENABLE_PIE` build option so that we can produce and compare non-PIE and PIE builds once we fix compatibility with PIE. * Forward `CMAKE_BUILD_TYPE` to vendored subprojects. Lack of this was causing the projects to be built without compiler optimizations, which doesn't play well with `FORTIFY_SOURCE`. On systems with glibc >= 2.40, facebook/folly#2519 is needed for this option to work. The overhead from these flags is likely to be limited, as many of them have been set by default for distribution packages for several years now.[1] [1] https://github.com/jvoisin/compiler-flags-distro
meta-codesync Bot
pushed a commit
to facebook/hhvm
that referenced
this pull request
Nov 25, 2025
Summary: Update and extend the list of hardening-related compiler flags used by HHVM to better represent modern distro defaults. * Convert the existing `ENABLE_SSP` build option into a new `ENABLE_HARDENING` option and put an updated list of security flags behind it. Both clang and GCC have been supporting these options for a while now, so we can set them irrespective of the compiler. * Put PIE-related options behind a separate `ENABLE_PIE` build option so that we can produce and compare non-PIE and PIE builds once we fix compatibility with PIE. * Forward `CMAKE_BUILD_TYPE` to vendored subprojects. Lack of this was causing the projects to be built without compiler optimizations, which doesn't play well with `FORTIFY_SOURCE`. On systems with glibc >= 2.40, facebook/folly#2519 is needed for this option to work. The overhead from these flags is likely to be limited, as many of them have been set by default for distribution packages for several years now.[1] [1] https://github.com/jvoisin/compiler-flags-distro Pull Request resolved: #9672 Reviewed By: Wilfred Differential Revision: D87347762 fbshipit-source-id: cdfbf29184e6022999e89258d7fa3475c971e01a
Contributor
|
FWIW we're seeing build failures here: and openat_2 has existed since at least glibc 2.7: https://github.com/bminor/glibc/blob/glibc-2.7/include/fcntl.h#L29 Are you sure this is correct? |
Wilfred
suggested changes
Nov 25, 2025
Contributor
Wilfred
left a comment
There was a problem hiding this comment.
See my comment on the PR.
Contributor
Author
|
So this was aiming to workaround the glibc 2.40+ changes introduced in bminor/glibc@86889e2 that only manifest with |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
On glibc >= 2.40, _FORTIFY_SOURCE overloads openat() when building with clang, causing the
decltypecall in Subprocess.cpp to fail since the target becomes ambiguous. So, explicitly specify our overload of choice in this case.Reproduce/test by setting
CMAKE_CXX_FLAGS=-D_FORTIFY_SOURCE=3 -DCMAKE_CXX_COMPILER=clang++.