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

clang: error: unknown argument: '-fstack-protector-strong' #1243

Closed
ryandesign opened this issue Jul 9, 2020 · 16 comments
Closed

clang: error: unknown argument: '-fstack-protector-strong' #1243

ryandesign opened this issue Jul 9, 2020 · 16 comments
Assignees
Labels
CMake Configuration issues related with CMake
Milestone

Comments

@ryandesign
Copy link

Describe the bug
Build fails:

clang: error: unknown argument: '-fstack-protector-strong'

Here is a full build log

To Reproduce
Build exiv2 0.27.3 on OS X 10.9 with Apple clang from Xcode

Expected behavior
successful build

Desktop (please complete the following information):

  • OS: OS X 10.9
  • Compiler & Version: Apple clang 6.0.0.6000057 (from Xcode 6.2)
  • Compilation mode and/or compiler flags: n/a

Additional context
The problem is the code in your cmake/compilerFlags.cmake which says:

if( (COMPILER_IS_GCC   AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 5.0) # Not in GCC 4.8
OR  (COMPILER_IS_CLANG AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 3.7) # Not in Clang 3.4.2
)
    add_compile_options(-fstack-protector-strong)
endif()

Apple clang and open source clang use different version numbering schemes. So even if this flag is supported in open source clang 3.7 and later, the version number of Apple clang in which it was added is a different number. I don't know what that number is specifically, but for comparison, it built fine on OS X 10.10 with Apple clang 7.0.2.7000181 (from Xcode 7.2.1). So it may be that support for this flag was added in Apple clang 7.

But as you see, using compiler version numbers to infer availability of features is brittle. It would be better to actually test the compiler to see whether it supports a flag.

@ryandesign ryandesign added the bug label Jul 9, 2020
@clanmills
Copy link
Collaborator

Welcome back @ryandesign I recall speaking with you about something 2 or 3 years ago.

OS X 10.9? That's rather elderly. The current macOS is Catalina:

1124 rmills@rmillsmbp:~/gnu/exiv2/team/book $ sw_vers
ProductName:	Mac OS X
ProductVersion:	10.15.5
BuildVersion:	19F101
1125 rmills@rmillsmbp:~/gnu/exiv2/team/book $ 

It's curious that Apple changed the name to "macOS" and nobody updated sw_vers.

We had issues on other platforms with that flag (Solaris, I think). You're right, it's probably better to test compile the flag. Would you like to propose a patch as you have the environment in which to test it. I have a VM with Yosemite, however I don't believe I have Xcode 6 on any of my machines.

@ryandesign
Copy link
Author

OS X 10.9? That's rather elderly.

Yes it is. It's nice to support even elderly systems when possible. MacPorts has automated build servers for Mac OS X 10.6 and later. We even still fix issues reported by users running Mac OS X 10.4 when we can.

The current macOS is Catalina:

Yes it is.

It's curious that Apple changed the name to "macOS" and nobody updated sw_vers.

I've heard that they've changed it in macOS Big Sur.

You're right, it's probably better to test compile the flag. Would you like to propose a patch as you have the environment in which to test it.

I don't know cmake very well so I couldn't propose a patch, but I can certainly test any changes you make.

@clanmills
Copy link
Collaborator

Yes. I prefer not to "drop" elderly platforms if retaining them is pain free. So on Visual Studio, we build all the way back to 2008.

Let me have a think what to do about this. @piponazo is our CMake expert.

Is there any urgency about this?

@ryandesign
Copy link
Author

No I can't really call problems affecting OS versions this old urgent. I've worked around the problem in MacPorts by requiring a newer compiler for now.

@clanmills
Copy link
Collaborator

I appreciate you working on MacPorts. I'm not an expert on CMake I'll try to get something done about this. It's too late now for v0.27.3 which shipped on 2020-06-30.

@ryandesign
Copy link
Author

It looks like maybe we want to use CheckCCompilerFlag.

@clanmills
Copy link
Collaborator

Good idea. I've downloaded Xcode 6.1 and the command-line tools on Yosemite and I'll look at this later today.

@clanmills clanmills added CMake Configuration issues related with CMake and removed bug labels Jul 9, 2020
@clanmills
Copy link
Collaborator

@ryandesign I've tried this on Yosemite with cmake 3.6 (we need 3.3.2 mininum). Doesn't seem to work. The 3.6 documentation has that command documented in Upper case. And that doesn't seem to work either.

I'm going to leave this for somebody else to investigate as I'm working on a book about Exiv2 and will retire when that's finished.

193 rmills@rmillsmm-yosemite:~/gnu/github/exiv2/0.27-maintenance/build $ cmake ..
-- ICONV_INCLUDE_DIR : /usr/include
-- ICONV_LIBRARIES : /usr/lib/libiconv.dylib
CMake Error at cmake/compilerFlags.cmake:26 (check_c_compiler_flag):
  Unknown CMake command "check_c_compiler_flag".
Call Stack (most recent call first):
  CMakeLists.txt:65 (include)


-- Configuring incomplete, errors occurred!
See also "/Users/rmills/gnu/github/exiv2/0.27-maintenance/build/CMakeFiles/CMakeOutput.log".
See also "/Users/rmills/gnu/github/exiv2/0.27-maintenance/build/CMakeFiles/CMakeError.log".
194 rmills@rmillsmm-yosemite:~/gnu/github/exiv2/0.27-maintenance/build $ make
make: *** No targets specified and no makefile found.  Stop.
195 rmills@rmillsmm-yosemite:~/gnu/github/exiv2/0.27-maintenance/build $ cmake ..
-- ICONV_INCLUDE_DIR : /usr/include
-- ICONV_LIBRARIES : /usr/lib/libiconv.dylib
CMake Error at cmake/compilerFlags.cmake:26 (CHECK_C_COMPILER_FLAG):
  Unknown CMake command "CHECK_C_COMPILER_FLAG".
Call Stack (most recent call first):
  CMakeLists.txt:65 (include)


-- Configuring incomplete, errors occurred!
See also "/Users/rmills/gnu/github/exiv2/0.27-maintenance/build/CMakeFiles/CMakeOutput.log".
See also "/Users/rmills/gnu/github/exiv2/0.27-maintenance/build/CMakeFiles/CMakeError.log".
196 rmills@rmillsmm-yosemite:~/gnu/github/exiv2/0.27-maintenance/build $ cmake --version
cmake version 3.6.3

CMake suite maintained and supported by Kitware (kitware.com/cmake).
197 rmills@rmillsmm-yosemite:~/gnu/github/exiv2/0.27-maintenance/build $ 

@ryandesign
Copy link
Author

I think cmake commands are case-insensitive so either CHECK_C_COMPILER_FLAG or check_c_compiler_flag should be fine, whichever style matches your existing code, but I think you'll need to include(CheckCCompilerFlag) before you invoke it.

@clanmills
Copy link
Collaborator

You're right. I didn't have the include thing and that's why it didn't work. I'll look at this again tomorrow.

@clanmills clanmills self-assigned this Jul 9, 2020
@clanmills clanmills added this to the v0.27.4 milestone Jul 9, 2020
@clanmills
Copy link
Collaborator

@ryandesign I've submitted a PR #1245 to branch 0.27-maintenance. I will test it this on my home build-server mingw, cygwin, msvc2019, linux, macOS, solaris, FreeBSD and NetBSD.

I've tested this on Yosemite with Xcode 6.1. When I installed python3, the test suite ran successfully on 0.27-maintenance.

I haven't submitted code to 'master' for a couple of years now as I want to retire and leave Exiv2 to other people. I have continued to maintain the 0.27-maintenance branch and hope Exiv2 v0.28 will be released in the next year. Once 0.28 ships, 0.27 "dots" will no longer be needed. I'm writing a book Image Metadata and Exiv2 Architecture to document my knowledge for a future maintainer. https://clanmills.com/exiv2/book

@clanmills
Copy link
Collaborator

@ryandesign Thanks very much for the review. I had noticed that I had a redundant define. I hadn't noticed stuff like --something. I am dyslexic and very error prone when doing this kind of edit.

Can you can give me the modified file or, even better, can you update the PR. If I wind my way though all your comments, I will make mistakes and introduce new errors.

You mentioned something about an alternative to check_c_compiler_flag and I don't know CMake well enough to comment. However @piponazo is a wizard at this stuff and I hope he'll look at this over the weekend.

May I grant you write permission to our repos and you can update the PR?

@ryandesign
Copy link
Author

Sure, I could add commits to the PR to make the changes I mentioned. Maybe I'll wait until @piponazo comments first.

@clanmills
Copy link
Collaborator

I can't be sure if @piponazo will get involved. Let's say, if he says nothing on Saturday, you can touch this on Sunday?

You're in Austin, TX? Man, you're up late. I've been to Austin several times. My sister and family live in Houston, TX. I'm in England and @piponazo is in Switzerland.

@clanmills
Copy link
Collaborator

I closed PR #1245 because it's wrong. I can't fix it because of my dyslexia.

@clanmills
Copy link
Collaborator

I believe this is fixed with #1271.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CMake Configuration issues related with CMake
Projects
None yet
Development

No branches or pull requests

2 participants