fortran-lang / fpm

Fortran Package Manager (fpm)
https://fpm.fortran-lang.org
MIT License
868 stars 97 forks source link

Add `debugoptimized` compilation profile #710

Open wyphan opened 2 years ago

wyphan commented 2 years ago

Description

Currently fpm only recognizes two compilation profiles: release and debug.

It would be nice if a third compilation profile equivalent to CMake's RelWithDebInfo (release with debugging information) can be added to fpm. This compilation profile would be useful for profiling the code and performance analysis at the source level (e.g. analyzing loops).

Possible Solution

Basically, enabling -g compiler flag while keeping the -O3 optimization level activated (for GFortran). Some compilers like nvfortran also have a dedicated -gopt flag for this purpose.

Additional Information

I would be happy to contribute a pull request, just lemme know which part of the code I should look into.

awvwgk commented 2 years ago

I usually default all my projects to RelWithDebInfo (CMake) / debugoptimized (meson), having this in fpm as well seems reasonable. We should try to come up with a better name than RelWithDebInfo because that usually seems to confuse users.

milancurcic commented 2 years ago

FWIW, debugoptimized reads clearly to me, and bonus points for consistency with meson.

LKedward commented 2 years ago

Can we just add the -g flag to our existing release profile instead of creating a new one? There shouldn't be any performance overhead for adding the -g flag, only an increase in file size. If people really want release without debug symbols they can always using strip.

debugoptimized sounds more like the -Og option in gcc (not sure if Intel has an equivalent). Maybe -Og should be our default for the debug profile.

From gcc optimization options:

-Og should be the optimization level of choice for the standard edit-compile-debug cycle

wyphan commented 2 years ago

@LKedward This is all I can find on Intel docs website: https://www.intel.com/content/www/us/en/develop/documentation/fortran-compiler-oneapi-dev-guide-and-reference/top/compilation/debugging/debugging-and-optimizations.html

sloorush commented 1 year ago

Was this fixed and the issue was not closed? or is this not what was supposed to be done(did I understand something wrong)?

https://github.com/fortran-lang/fpm/blob/440272aff77c769a1b2c699f341ccfff10c3c525/src/fpm_compiler.f90#L137-L138