Skip to content
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

Don't require CMake 3.18 or later #3510

Merged
merged 1 commit into from
Feb 16, 2023
Merged

Conversation

kou
Copy link
Contributor

@kou kou commented Feb 14, 2023

fix #3500

CMake 3.18 or later was required by #3392. Because it uses CheckLinkerFlag. But requiring CMake 3.18 or later is a bit aggressive. Because Ubuntu 20.04 LTS still uses CMake 3.16.3: https://packages.ubuntu.com/search?keywords=cmake

This change disables -z noexecstack check with old CMake. This will not break any existing users. Because users who need -z noexecstack must already use CMake 3.18 or later.

@facebook-github-bot
Copy link

Hi @kou!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@facebook-github-bot
Copy link

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

1 similar comment
@facebook-github-bot
Copy link

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@botanegg
Copy link

Instead of just disable this flag it can be done by try_compile like this:
https://github.com/mctools/ncrystal/blob/a263fb0efa4550239ef9fe7bb22e63d951d56206/CMakeLists.txt#L201-L216

@kou
Copy link
Contributor Author

kou commented Feb 15, 2023

The shim implementation will increase maintenance cost a bit.
Do we need to implement it?

The author of #3392 uses CheckLinkerFlag. It seems that users who need this feature use newer CMake. So the shim implementation may not be needed for real users.

If the shim implementation is needed for this project, I can do it.

Copy link
Contributor

@terrelln terrelln left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR @kou!

@terrelln
Copy link
Contributor

I think it is reasonable to simply disable the extra ldflags when check_linker_flags() is not available, since the only flags we currently use are optional.

I think we should just add a comment to the function to clarify that the ldflags don't get added for old cmake versions.

@@ -20,7 +29,11 @@ function(EnableCompilerFlag _flag _C _CXX _LD)
endif ()
endif ()
if (_LD)
CHECK_LINKER_FLAG(C ${_flag} LD_FLAG_${varname})
if (ZSTD_HAVE_CHECK_LINKER_FLAG)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you just add a comment to this function that says that it doesn't add ldflags for older cmake versions? In case that we need to add other ldflags that are non-optional later.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It makes sense. I've add a comment:

        # We never add a linker flag with CMake < 3.18. We will
        # implement CHECK_LINKER_FLAG() like feature for CMake < 3.18
        # or require CMake >= 3.18 when we need to add a required
        # linker flag in future.

Does this make sense?

fix facebook#3500

CMake 3.18 or later was required by facebook#3392. Because it uses
`CheckLinkerFlag`. But requiring CMake 3.18 or later is a bit
aggressive. Because Ubuntu 20.04 LTS still uses CMake 3.16.3:
https://packages.ubuntu.com/search?keywords=cmake

This change disables `-z noexecstack` check with old CMake. This will
not break any existing users. Because users who need `-z noexecstack`
must already use CMake 3.18 or later.
@kou kou force-pushed the cmake-not-require-3.18 branch from e6d5b5d to 71094bb Compare February 15, 2023 21:29
Copy link
Contributor

@terrelln terrelln left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @kou!

@terrelln terrelln merged commit 8420502 into facebook:dev Feb 16, 2023
@kou kou deleted the cmake-not-require-3.18 branch February 17, 2023 03:49
@kou
Copy link
Contributor Author

kou commented Feb 17, 2023

@terrelln Thanks! Do you have a plan to release a new version with this change soon? (If it's done, apache/arrow can use the latest Zstandard. But it's not a blocker. So apache/arrow can wait a new version.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CMake: bump min CMake version to 3.18 or remove usage of check_linker_flag()
4 participants