vmagnin / gtk-fortran

A GTK / Fortran binding. The documentation is in the Wiki tab.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

User provided compile and link arguments are ignored

awvwgk opened this issue · comments

Describe the bug

Compile and link arguments from FFLAGS and LDFLAGS are overwritten in

set(CMAKE_Fortran_FLAGS_RELEASE "-pthread -O3 -mtune=native -march=native")
if (UNIX)
set(CMAKE_EXE_LINKER_FLAGS "-rdynamic")
endif()

Expected behavior

Respect user provided arguments in FFLAGS and LDFLAGS, ignoring them can lead to build failures.

To Reproduce
Steps to reproduce the behavior:

❯ mamba create -n gtk4 glib gtk4 plplot cmake ninja pkg-config fortran-compiler
❯ mamba activate gtk4
❯ echo $FFLAGS
-march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -isystem /home/awvwgk/software/opt/conda/envs/gtk4/include
❯ echo $LDFLAGS
-Wl,-O2 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now -Wl,--disable-new-dtags -Wl,--gc-sections -Wl,--allow-shlib-undefined -Wl,-rpath,/home/awvwgk/software/opt/conda/envs/gtk4/lib -Wl,-rpath-link,/home/awvwgk/software/opt/conda/envs/gtk4/lib -L/home/awvwgk/software/opt/conda/envs/gtk4/lib
❯ cmake ${CMAKE_ARGS} -B _build -G Ninja
-- The Fortran compiler identification is GNU 10.3.0
-- Detecting Fortran compiler ABI info
-- Detecting Fortran compiler ABI info - done
-- Check for working Fortran compiler: /home/awvwgk/software/opt/conda/envs/gtk4/bin/x86_64-conda-linux-gnu-gfortran - skipped
-- Building gtk-4-fortran 4.1.0
-- GNUInstallDirs: /usr/local lib include bin share share/man
-- System: Linux 5.10.98-1-MANJARO x86_64
-- Compiler: GNU 10.3.0 /home/awvwgk/software/opt/conda/envs/gtk4/bin/x86_64-conda-linux-gnu-gfortran
-- Build type is: release
-- Compilation flags: -pthread -O3 -mtune=native -march=native
-- Found PkgConfig: /home/awvwgk/software/opt/conda/envs/gtk4/bin/pkg-config (found version "0.29.2") 
-- Checking for module 'gtk4'
--   Found gtk4, version 4.6.0
-- Checking for module 'plplot-fortran'
--   Found plplot-fortran, version 5.15.0
-- Checking for module 'plplot'
--   Found plplot, version 5.15.0
-- Configuring done
-- Generating done
CMake Warning:
  Manually-specified variables were not used by the project:

    CMAKE_CXX_COMPILER_AR
    CMAKE_CXX_COMPILER_RANLIB
    CMAKE_C_COMPILER_AR
    CMAKE_C_COMPILER_RANLIB


-- Build files have been written to: /home/awvwgk/projects/src/git/gtk-fortran/_build

User provided FFLAGS do not show up in configure output

Your system:

Testing 225e25b

OS version
❯ mamba info
...
     active environment : gtk4
    active env location : /home/awvwgk/software/opt/conda/envs/gtk4
            shell level : 2
       user config file : /home/awvwgk/.condarc
 populated config files : /home/awvwgk/software/opt/conda/.condarc
          conda version : 4.11.0
    conda-build version : not installed
         python version : 3.9.9.final.0
       virtual packages : __linux=5.10.98=0
                          __glibc=2.33=0
                          __unix=0=0
                          __archspec=1=x86_64
       base environment : /home/awvwgk/software/opt/conda  (writable)
      conda av data dir : /home/awvwgk/software/opt/conda/etc/conda
  conda av metadata url : None
           channel URLs : https://conda.anaconda.org/conda-forge/linux-64
                          https://conda.anaconda.org/conda-forge/noarch
          package cache : /home/awvwgk/software/opt/conda/pkgs
                          /home/awvwgk/.conda/pkgs
       envs directories : /home/awvwgk/software/opt/conda/envs
                          /home/awvwgk/.conda/envs
               platform : linux-64
             user-agent : conda/4.11.0 requests/2.27.1 CPython/3.9.9 Linux/5.10.98-1-MANJARO manjaro/21.2.3 glibc/2.33
                UID:GID : 1000:1000
             netrc file : None
           offline mode : False

Compiler version
❯ mamba list
# packages in environment at /home/awvwgk/software/opt/conda/envs/gtk4:
#
# Name                    Version                   Build  Channel
_libgcc_mutex             0.1                 conda_forge    conda-forge
_openmp_mutex             4.5                       1_gnu    conda-forge
binutils                  2.36.1               hdd6e379_2    conda-forge
binutils_impl_linux-64    2.36.1               h193b22a_2    conda-forge
binutils_linux-64         2.36                 hf3e587d_5    conda-forge
bzip2                     1.0.8                h7f98852_4    conda-forge
c-ares                    1.18.1               h7f98852_0    conda-forge
c-compiler                1.4.0                h166bdaf_0    conda-forge
ca-certificates           2021.10.8            ha878542_0    conda-forge
cairo                     1.16.0            ha00ac49_1009    conda-forge
cmake                     3.22.2               h1021d11_0    conda-forge
epoxy                     1.5.9                h7f98852_0    conda-forge
expat                     2.4.6                h27087fc_0    conda-forge
font-ttf-dejavu-sans-mono 2.37                 hab24e00_0    conda-forge
font-ttf-inconsolata      3.000                h77eed37_0    conda-forge
font-ttf-source-code-pro  2.038                h77eed37_0    conda-forge
font-ttf-ubuntu           0.83                 hab24e00_0    conda-forge
fontconfig                2.13.96              ha180cfb_0    conda-forge
fonts-conda-ecosystem     1                             0    conda-forge
fonts-conda-forge         1                             0    conda-forge
fortran-compiler          1.4.0                h2a4ca65_0    conda-forge
freetype                  2.10.4               h0708190_1    conda-forge
fribidi                   1.0.10               h36c2ea0_0    conda-forge
gcc                       10.3.0               he2824d0_5    conda-forge
gcc_impl_linux-64         10.3.0              hf2f2afa_12    conda-forge
gcc_linux-64              10.3.0               hc39de41_5    conda-forge
gdk-pixbuf                2.42.6               h04a7f16_0    conda-forge
gettext                   0.19.8.1          h73d1719_1008    conda-forge
gfortran                  10.3.0               h18518b4_5    conda-forge
gfortran_impl_linux-64    10.3.0              h73f4979_12    conda-forge
gfortran_linux-64         10.3.0               hb09a455_5    conda-forge
glib                      2.70.2               h780b84a_4    conda-forge
glib-tools                2.70.2               h780b84a_4    conda-forge
graphite2                 1.3.13            h58526e2_1001    conda-forge
gtk4                      4.6.0                h6fd0243_1    conda-forge
harfbuzz                  3.4.0                hb4a5f5f_0    conda-forge
hicolor-icon-theme        0.17                 ha770c72_2    conda-forge
icu                       69.1                 h9c3ff4c_0    conda-forge
jbig                      2.1               h7f98852_2003    conda-forge
jpeg                      9e                   h7f98852_0    conda-forge
kernel-headers_linux-64   2.6.32              he073ed8_15    conda-forge
krb5                      1.19.2               h48eae69_3    conda-forge
ld_impl_linux-64          2.36.1               hea4e1c9_2    conda-forge
lerc                      3.0                  h9c3ff4c_0    conda-forge
libcups                   2.3.3                hf5a7f15_1    conda-forge
libcurl                   7.81.0               h494985f_0    conda-forge
libdeflate                1.10                 h7f98852_0    conda-forge
libedit                   3.1.20191231         he28a2e2_2    conda-forge
libev                     4.33                 h516909a_1    conda-forge
libffi                    3.4.2                h7f98852_5    conda-forge
libgcc-devel_linux-64     10.3.0              he6cfe16_12    conda-forge
libgcc-ng                 11.2.0              h1d223b6_12    conda-forge
libgfortran-ng            11.2.0              h69a702a_12    conda-forge
libgfortran5              11.2.0              h5c6108e_12    conda-forge
libglib                   2.70.2               h174f98d_4    conda-forge
libgomp                   11.2.0              h1d223b6_12    conda-forge
libgraphene               1.10.6               h76c114f_0    conda-forge
libiconv                  1.16                 h516909a_0    conda-forge
libnghttp2                1.46.0               ha19adfc_0    conda-forge
libnsl                    2.0.0                h7f98852_0    conda-forge
libpng                    1.6.37               h21135ba_2    conda-forge
libsanitizer              10.3.0              h26c7422_12    conda-forge
libssh2                   1.10.0               ha35d2d1_2    conda-forge
libstdcxx-ng              11.2.0              he4da1e4_12    conda-forge
libtiff                   4.3.0                h542a066_3    conda-forge
libuuid                   2.32.1            h7f98852_1000    conda-forge
libuv                     1.43.0               h7f98852_0    conda-forge
libwebp-base              1.2.2                h7f98852_1    conda-forge
libxcb                    1.13              h7f98852_1004    conda-forge
libxml2                   2.9.12               h885dcf4_1    conda-forge
libzlib                   1.2.11            h36c2ea0_1013    conda-forge
lz4-c                     1.9.3                h9c3ff4c_1    conda-forge
ncurses                   6.3                  h9c3ff4c_0    conda-forge
ninja                     1.10.2               h4bd325d_1    conda-forge
openssl                   3.0.0                h7f98852_2    conda-forge
pango                     1.50.3               h9967ed3_0    conda-forge
pcre                      8.45                 h9c3ff4c_0    conda-forge
pip                       22.0.3             pyhd8ed1ab_0    conda-forge
pixman                    0.40.0               h36c2ea0_0    conda-forge
pkg-config                0.29.2            h36c2ea0_1008    conda-forge
plplot                    5.15.0               h669245a_0    conda-forge
pthread-stubs             0.4               h36c2ea0_1001    conda-forge
python                    3.10.2          hc74c709_3_cpython    conda-forge
python_abi                3.10                    2_cp310    conda-forge
readline                  8.1                  h46c0cb4_0    conda-forge
rhash                     1.4.1                h7f98852_0    conda-forge
setuptools                60.9.3          py310hff52083_0    conda-forge
sqlite                    3.37.0               h9cd32fc_0    conda-forge
sysroot_linux-64          2.12                he073ed8_15    conda-forge
tk                        8.6.12               h27826a3_0    conda-forge
tzdata                    2021e                he74cb21_0    conda-forge
wheel                     0.37.1             pyhd8ed1ab_0    conda-forge
xorg-compositeproto       0.4.2             h7f98852_1001    conda-forge
xorg-damageproto          1.2.1             h7f98852_1002    conda-forge
xorg-fixesproto           5.0               h7f98852_1002    conda-forge
xorg-inputproto           2.3.2             h7f98852_1002    conda-forge
xorg-kbproto              1.0.7             h7f98852_1002    conda-forge
xorg-libice               1.0.10               h7f98852_0    conda-forge
xorg-libsm                1.2.3             hd9c2040_1000    conda-forge
xorg-libx11               1.6.12               h36c2ea0_0    conda-forge
xorg-libxau               1.0.9                h7f98852_0    conda-forge
xorg-libxcomposite        0.4.5                h7f98852_0    conda-forge
xorg-libxcursor           1.2.0                h516909a_0    conda-forge
xorg-libxdamage           1.1.5                h7f98852_0    conda-forge
xorg-libxdmcp             1.1.3                h7f98852_0    conda-forge
xorg-libxext              1.3.4                h516909a_0    conda-forge
xorg-libxfixes            5.0.3             h516909a_1004    conda-forge
xorg-libxi                1.7.10               h516909a_0    conda-forge
xorg-libxinerama          1.1.4             h9c3ff4c_1001    conda-forge
xorg-libxrandr            1.5.2                h516909a_1    conda-forge
xorg-libxrender           0.9.10            h516909a_1002    conda-forge
xorg-randrproto           1.5.0             h7f98852_1001    conda-forge
xorg-renderproto          0.11.1            h7f98852_1002    conda-forge
xorg-util-macros          1.19.3               h7f98852_0    conda-forge
xorg-xextproto            7.3.0             h7f98852_1002    conda-forge
xorg-xineramaproto        1.2.1             h7f98852_1001    conda-forge
xorg-xproto               7.0.31            h7f98852_1007    conda-forge
xz                        5.2.5                h516909a_1    conda-forge
zlib                      1.2.11            h36c2ea0_1013    conda-forge
zstd                      1.5.2                ha95c52a_0    conda-forge

Good point. I will explore that kind of syntax:

set(CMAKE_Fortran_FLAGS_RELEASE "${CMAKE_Fortran_FLAGS_RELEASE} -pthread -O3 -mtune=native -march=native") 

or

list(APPEND CMAKE_Fortran_FLAGS_RELEASE "-pthread -O3 -mtune=native -march=native")

I will try to work on it these next days.

https://bytefreaks.net/programming-2/two-ways-to-append-a-new-argument-to-cmake_args-list-for-externalproject_add

I would appreciate not overwriting or appending to user flags, especially I don't want to see -march=native popping up when compiling a package for distribution.

How about using CMAKE_Fortran_FLAGS_RELEASE_INIT?