Skip to content

Commit

Permalink
Merge pull request #590 from ax3l/topic-rpathSupport
Browse files Browse the repository at this point in the history
Linker: Use RPath
  • Loading branch information
WeiqunZhang committed Oct 14, 2019
2 parents 359987a + f20376b commit fe5a776
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
8 changes: 8 additions & 0 deletions Docs/sphinx_documentation/source/BuildingAMReX.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ list of important variables.
+------------+-------------------------------------+-------------+
| USE_OMP | TRUE or FALSE | FALSE |
+------------+-------------------------------------+-------------+
| USE_RPATH | TRUE or FALSE | FALSE |
+------------+-------------------------------------+-------------+

.. raw:: latex

Expand Down Expand Up @@ -83,6 +85,12 @@ be obvious. When ``DEBUG = TRUE``, aggressive compiler optimization flags are
turned off and assertions in  source code are turned on. For production runs,
``DEBUG`` should be set to FALSE.

The variable ``USE_RPATH`` controls the link mechanism to dependent libraries.
If enabled, the library path at link time will be saved as a
`rpath hint <https://en.wikipedia.org/wiki/Rpath>`_ in created binaries.
When disabled, library paths must be provided via ``export LD_LIBRARY_PATH``
hints at runtime.

After defining these make variables, a number of files, ``Make.defs,
Make.package`` and ``Make.rules``, are included in the GNUmakefile. AMReX-based
applications do not need to include all directories in AMReX; an application
Expand Down
14 changes: 13 additions & 1 deletion Tools/GNUMake/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ else
PRECISION := DOUBLE
endif

ifdef USE_RPATH
USE_RPATH := $(strip $(USE_RPATH))
else
# the syntax we use below works for all compilers but CCE "classic"
# we plan to enable this feature by default in the future
USE_RPATH := FALSE
endif

ifdef DEBUG
DEBUG := $(strip $(DEBUG))
else
Expand Down Expand Up @@ -717,7 +725,11 @@ CPPFLAGS += $(DEFINES)

libraries = $(LIBRARIES) $(XTRALIBS)

LDFLAGS += -L. $(addprefix -L, $(LIBRARY_LOCATIONS))
ifeq ($(USE_RPATH),TRUE)
LDFLAGS += -Xlinker -rpath -Xlinker . $(addprefix -Xlinker -rpath -Xlinker , $(LIBRARY_LOCATIONS))
else
LDFLAGS += -L. $(addprefix -L, $(LIBRARY_LOCATIONS))
endif

machineSuffix = $(lowercase_comp)$(archSuffix)$(PrecisionSuffix)$(DebugSuffix)$(ProfSuffix)$(MProfSuffix)$(BTSuffix)$(MPISuffix)$(UPCXXSuffix)$(OMPSuffix)$(ACCSuffix)$(GPUSuffix)$(USERSuffix)

Expand Down

0 comments on commit fe5a776

Please sign in to comment.