Bug 255913 - devel/aws-c-common: let CMake detect -moutline-atomics correctly
Summary: devel/aws-c-common: let CMake detect -moutline-atomics correctly
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Danilo Egea Gondolfo
URL:
Keywords:
Depends on:
Blocks: 255570
  Show dependency treegraph
 
Reported: 2021-05-15 19:50 UTC by Dimitry Andric
Modified: 2021-05-29 14:16 UTC (History)
0 users

See Also:
bugzilla: maintainer-feedback? (danilo)


Attachments
Let CMake detect -moutline-atomics correctly (1.05 KB, text/plain)
2021-05-15 19:50 UTC, Dimitry Andric
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Dimitry Andric freebsd_committer 2021-05-15 19:50:09 UTC
Created attachment 224980 [details]
Let CMake detect -moutline-atomics correctly

During an exp-run for llvm 12 (see bug 255570), it turned out that security/aws-c-cal does not build with clang 12.0.0 [1], at least not on amd64:

-- The C compiler identification is Clang 12.0.0
[...]
-- Performing Test HAS_MOUTLINE_ATOMICS
-- Performing Test HAS_MOUTLINE_ATOMICS - Success
[...]
FAILED: CMakeFiles/aws-c-cal.dir/source/der.c.o 
/usr/bin/cc -DAWS_CAL_EXPORTS -DAWS_CAL_USE_IMPORT_EXPORT -DAWS_COMMON_USE_IMPORT_EXPORT -DHAVE_SYSCONF -Daws_c_cal_EXPORTS -I/wrkdirs/usr/ports/security/aws-c-cal/work/aws-c-cal-0.4.5/include -isystem /usr/local/include -O2 -pipe  -fstack-protector-strong -fno-strict-aliasing -O2 -pipe  -fstack-protector-strong -fno-strict-aliasing -fPIC -Wall -Werror -Wstrict-prototypes -fno-omit-frame-pointer -pedantic -Wno-long-long -fPIC -moutline-atomics -Wgnu -Wno-gnu-zero-variadic-macro-arguments -fvisibility=hidden -std=gnu99 -MD -MT CMakeFiles/aws-c-cal.dir/source/der.c.o -MF CMakeFiles/aws-c-cal.dir/source/der.c.o.d -o CMakeFiles/aws-c-cal.dir/source/der.c.o -c /wrkdirs/usr/ports/security/aws-c-cal/work/aws-c-cal-0.4.5/source/der.c
cc: error: The 'x86_64' architecture does not support -moutline-atomics; flag ignored [-Werror,-Woption-ignored]

This port uses /usr/local/lib/cmake/AwsCFlags.cmake to detect the -moutline-atomics flag, but it does so by checking if the compiler prints an *error* when using the flag. It could be debated that CMake's check_c_compiler_flag() functionality is rather broken in that sense, as it does not exhaustively scan for warnings from the compiler.

On the other hand, security/aws-c-cal compiles with -Werror, so then you get an error for such warnings. Instead of hacking around it in security/aws-c-cal, I propose to fix it in devel/aws-c-common instead, simply by adding -Werror to the HAS_MOUTLINE_ATOMICS check.

This will ensure that it does *not* get enabled on x86, where it is not functional, and will still get enabled on e.g. aarch64, for which this flag is meant.

[1] http://package22.nyi.freebsd.org/data/mainamd64PR255570-default/2021-05-08_16h02m24s/logs/errors/aws-c-cal-0.4.5.log
Comment 1 commit-hook freebsd_committer 2021-05-29 14:09:38 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=0d25df4a18898c9434f2c7c7f06c833f602ae3fc

commit 0d25df4a18898c9434f2c7c7f06c833f602ae3fc
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2021-05-15 19:41:55 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2021-05-29 14:08:19 +0000

    devel/aws-c-common: detect -moutline-atomics correctly

    During an exp-run for llvm 12 (see bug 255570), it turned out that
    security/aws-c-cal does not build with clang 12.0.0, at least not on
    amd64:

    -- The C compiler identification is Clang 12.0.0
    [...]
    -- Performing Test HAS_MOUTLINE_ATOMICS
    -- Performing Test HAS_MOUTLINE_ATOMICS - Success
    [...]
    FAILED: CMakeFiles/aws-c-cal.dir/source/der.c.o
    /usr/bin/cc -DAWS_CAL_EXPORTS -DAWS_CAL_USE_IMPORT_EXPORT -DAWS_COMMON_USE_IMPORT_EXPORT -DHAVE_SYSCONF -Daws_c_cal_EXPORTS -I/wrkdirs/usr/ports/security/aws-c-cal/work/aws-c-cal-0.4.5/include -isystem /usr/local/include -O2 -pipe  -fstack-protector-strong -fno-strict-aliasing -O2 -pipe  -fstack-protector-strong -fno-strict-aliasing -fPIC -Wall -Werror -Wstrict-prototypes -fno-omit-frame-pointer -pedantic -Wno-long-long -fPIC -moutline-atomics -Wgnu -Wno-gnu-zero-variadic-macro-arguments -fvisibility=hidden -std=gnu99 -MD -MT CMakeFiles/aws-c-cal.dir/source/der.c.o -MF CMakeFiles/aws-c-cal.dir/source/der.c.o.d -o CMakeFiles/aws-c-cal.dir/source/der.c.o -c /wrkdirs/usr/ports/security/aws-c-cal/work/aws-c-cal-0.4.5/source/der.c
    cc: error: The 'x86_64' architecture does not support -moutline-atomics; flag ignored [-Werror,-Woption-ignored]

    This port uses /usr/local/lib/cmake/AwsCFlags.cmake to detect the
    -moutline-atomics flag, but it does so by checking if the compiler
    prints an *error* when using the flag. It could be debated that CMake's
    check_c_compiler_flag() functionality is rather broken in that sense, as
    it does not exhaustively scan for warnings from the compiler.

    On the other hand, security/aws-c-cal compiles with -Werror, so then you
    get an error for such warnings. Instead of hacking around it in
    security/aws-c-cal, fix it in devel/aws-c-common instead, simply by
    adding -Werror to the HAS_MOUTLINE_ATOMICS check.

    This will ensure that it does *not* get enabled on x86, where it is not
    functional, and will still get enabled on e.g. aarch64, for which this
    flag is meant.

    Approved by:    maintainer timeout (2 weeks)
    PR:             255913
    MFH:            2021Q2

 devel/aws-c-common/files/patch-cmake_AwsCFlags.cmake (new) | 11 +++++++++++
 1 file changed, 11 insertions(+)