datetime-fortran
datetime-fortran copied to clipboard
CMake uses different compiler flags to autotools
Please note that the static library built via CMake is built with different flags compared to when it is built with Autotools.
e.g. Cmake:
/usr/bin/f95 -O3 -DNDEBUG -O3 -Jinclude -c [...]/datetime-fortran.git/src/datetime_module.f90 -o CMakeFiles/datetime.dir/src/datetime_module.f90.o
...
/usr/bin/ar qc lib/libdatetime.a CMakeFiles/datetime.dir/src/datetime_module.f90.o
/usr/bin/ranlib lib/libdatetime.a
e.g. Autotools:
gfortran -c -Wall datetime_module.f90
...
ar ruv libdatetime.a datetime_module.o
ar: `u' modifier ignored since `D' is the default (see `U')
ar: creating libdatetime.a
a - datetime_module.o
Environment:
$ gfortran --version
GNU Fortran (Debian 12.2.0-3) 12.2.0
$ ar --version
GNU ar (GNU Binutils for Debian) 2.39
Thanks! As I understand it #76 doesn't address this, right? We can easily add a default -O3
to the autotools build.
https://github.com/wavebitscientific/datetime-fortran/pull/75 does not address this issue.
Is -O3 preferred over -O2 by the fortran community?
Notes:
$ gfortran --version
GNU Fortran (GCC) 8.5.0 20210514 (Red Hat 8.5.0-10)
$ ar --version
GNU ar version 2.30-113.el8
/bin/f95 -O3 -DNDEBUG -O3 -Jinclude -c [...]/datetime-fortran.git/src/datetime_module.f90 -o CMakeFiles/datetime.dir/src/datetime_module.f90.o
...
/bin/ar qc lib/libdatetime.a CMakeFiles/datetime.dir/src/datetime_module.f90.o
/bin/ranlib lib/libdatetime.a
gfortran -c -Wall datetime_module.f90
...
ar ruv libdatetime.a datetime_module.o
ar: creating libdatetime.a
a - datetime_module.o
I think -O3
is fine to use as a default.
I haven't seen any problems with -O3 on modern compilers. There are corner cases where -O2 is preferred by certain projects or certain applications, but those users already know that can can apply option cmake -DCMAKE_Fortran_FLAGS=-O2