-
Notifications
You must be signed in to change notification settings - Fork 116
Fix -fPIC for C sources #1206
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
base: main
Are you sure you want to change the base?
Fix -fPIC for C sources #1206
Conversation
Use get_debug_compile_flags and get_release_compile_flags for pulling the default flags instead of hard-coding them in features_collection.f90.
A better solution would be to define getters for CFLAGS i.e. get_debug_compile_c_flags and get_release_compile_c_flags. Use them to pull the default flags for C sources.
perazz
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you so much for this PR @MilanSkocic -
Please generalize default_variant instead:
- add character(*), optional, intent(in) :: c_flags, cxx_flags arguments
- set them if present
- customize the compiler/OS default variants for both debug and release by adding the PIC flag (may not be the same on all platforms)
|
That's what I wanted to do by adding optional arguments. |
Imports not needed for now. They will be necessary if a solution by using functions defined in the module `fpm_compiler.F90` is decided.
All variants, except those for OS_WINDOWS, will accept the -fPIC flag for C/C++ sources. A more complete set of flags for C/C++ sources was added for the gcc compiler. For the other compilers, additional work might be needed to define the correct flags mathcing those passed for Fortran sources.
All variants, except those for OS_WINDOWS, will accept the -fPIC flag for C/C++ sources. A more complete set of flags for C/C++ sources was added for the gcc compiler. For the other compilers, additional work might be needed to define the correct flags mathcing those passed for Fortran sources.
The argument flags was made optional and 2 additional optional arguments were added i.e. c_flags and cxx_flags. The default values for featture%flags, feature%c_flags and feature%cxx_flags were set to an empty string. The latter are set if the respective optional arguments are defined. flags, c_flags and cxx_flags are set from the callers default_release_feature and default_debug_feature. This way there won't be backward compatibility as the flags were already defined in the callers. For now, the c_flags and cxx_flags are limited to the fPIC flag necessary for the shared libraries except for the variant with the gcc compiler where equivalent c_flags to flags were defined. More work is needed to complete the set of c_flags and cxx_flags for other variants.
|
I have generalized |
Issue #1205 highlighted that the
fPIC, necessary for shared libraries, was not passed for C sources either with profilereleaseordebug.For
CFLAGS, a hot fix was applied i.e. the flag is hard-coded 353ec23.Equivalent function of
fpm_compiler.F90/get_<debug/release>_compile_flagsshould be implemented for pulling default flags for C sources as it is the case for Fortran sources.The
FFLAGSare hard-coded both profiles (releaseanddebug) infeature_collection/default_<release/debug>_feature(). However, it might better to pull from default compile flags defined infpm_compiler.F90/get_<release/debug>_compile_flag(cb7d15c)