Enable MPAS to be compiled into position-independent code#307
Enable MPAS to be compiled into position-independent code#307mgduda merged 1 commit intoMPAS-Dev:developfrom
Conversation
In order to allow MPAS code to be called from other systems with more flexibility, e.g., as a shared library, this commit adds a new compile option, SHAREDLIB=true, that causes all source files to be compiled with appropriate flags to generate position-independent code. The appropriate flags to use are not known for all compilers with build targets in the top-level Makefile, and if SHAREDLIB=true is specified for such a build target, an error like the following will be generated: *** Position-independent code was requested but PIC flags are not available. Please add PIC flags for the 'ftn' target. Stop.
|
This PR introduces a subset of the changes from PR #106 . |
mark-petersen
left a comment
There was a problem hiding this comment.
Test merged into ocean/develop, compiled with gnu and intel, passes ocean regression test. This looks fine by inspection. I don't understand what position-independent code is, but it is protected by a flag regardless.
matthewhoffman
left a comment
There was a problem hiding this comment.
Approved by inspection and @mark-petersen 's testing.
|
@mark-petersen I'm not sure this is the best explanation, but position-independent code is code that is compiled such that it makes no assumptions about the absolute locations of symbols (e.g., subroutines). Position-independent code is necessary if one wishes to create a shared library, which might be loaded anywhere in memory at run-time. As you pointed out, the changes in this PR only add additional compiler flags if |
This merge enables MPAS to be compiled into position-independent code. In order to allow MPAS code to be called from other systems with more flexibility, e.g., as a shared library, this commit adds a new compile option, SHAREDLIB=true, that causes all source files to be compiled with appropriate flags to generate position-independent code. The appropriate flags to use are not known for all compilers with build targets in the top-level Makefile, and if SHAREDLIB=true is specified for such a build target, an error like the following will be generated: *** Position-independent code was requested but PIC flags are not available. Please add PIC flags for the 'ftn' target. Stop. * framework/external_lib_support: Enable MPAS to be compiled into position-independent code
…ev#307) This merge enables MPAS to be compiled into position-independent code. In order to allow MPAS code to be called from other systems with more flexibility, e.g., as a shared library, this commit adds a new compile option, SHAREDLIB=true, that causes all source files to be compiled with appropriate flags to generate position-independent code. The appropriate flags to use are not known for all compilers with build targets in the top-level Makefile, and if SHAREDLIB=true is specified for such a build target, an error like the following will be generated: *** Position-independent code was requested but PIC flags are not available. Please add PIC flags for the 'ftn' target. Stop. * framework/external_lib_support: Enable MPAS to be compiled into position-independent code
This merge enables MPAS to be compiled into positiion-independent code.
In order to allow MPAS code to be called from other systems with more
flexibility, e.g., as a shared library, this commit adds a new compile option,
SHAREDLIB=true, that causes all source files to be compiled with appropriateflags to generate position-independent code.
The appropriate flags to use are not known for all compilers with build
targets in the top-level Makefile, and if SHAREDLIB=true is specified for
such a build target, an error like the following will be generated: