Skip to content

Commit 7a0b1f2

Browse files
committed
Ensure that libdir is always first in search path
Switch the ordering of both the -L and rpath/runpath arguments added by the wrapper compiler so that the install's libdir is always the first in the list of paths to search. Previously, the component-related paths were added first, which could cause applications to find an errant (to us, anyway) libmpi. Signed-off-by: Brian Barrett <bbarrett@amazon.com> (cherry picked from commit bed9f20) (cherry picked from commit 99c795d)
1 parent 4ef1243 commit 7a0b1f2

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

config/opal_setup_wrappers.m4

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ dnl and Technology (RIST). All rights reserved.
1717
dnl Copyright (c) 2016 IBM Corporation. All rights reserved.
1818
dnl Copyright (c) 2020 Triad National Security, LLC. All rights
1919
dnl reserved.
20+
dnl Copyright (c) 2021 Amazon.com, Inc. or its affiliates.
21+
dnl All Rights reserved.
2022
dnl $COPYRIGHT$
2123
dnl
2224
dnl Additional copyrights may follow
@@ -264,9 +266,11 @@ AC_DEFUN([RPATHIFY_LDFLAGS_INTERNAL],[
264266
esac
265267
done
266268

267-
# Now add in the RPATH args for @{libdir}, and the RUNPATH args
269+
# add in the RPATH args for @{libdir}, and the RUNPATH
270+
# args. The install libdir goes first, so that we prefer
271+
# our libmpi over any imposter libmpi we might find.
268272
rpath_tmp=`echo ${$2} | sed -e s/LIBDIR/@{libdir}/`
269-
$1="${$1} $rpath_out $rpath_tmp ${$3}"
273+
$1="${$1} $rpath_tmp $rpath_out ${$3}"
270274
])
271275
OPAL_VAR_SCOPE_POP
272276
])

opal/tools/wrappers/opal_wrapper.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
* Copyright (c) 2010 Oracle and/or its affiliates. All rights reserved.
1616
* Copyright (c) 2015 Research Organization for Information Science
1717
* and Technology (RIST). All rights reserved.
18+
* Copyright (c) 2018-2021 Amazon.com, Inc. or its affiliates. All Rights reserved.
1819
* $COPYRIGHT$
1920
*
2021
* Additional copyrights may follow
@@ -322,7 +323,7 @@ data_callback(const char *key, const char *value)
322323
char *line;
323324
asprintf(&line, OPAL_INCLUDE_FLAG"%s",
324325
options_data[parse_options_idx].path_includedir);
325-
opal_argv_append_nosize(&options_data[parse_options_idx].preproc_flags, line);
326+
opal_argv_prepend_nosize(&options_data[parse_options_idx].preproc_flags, line);
326327
free(line);
327328
}
328329
}
@@ -333,7 +334,7 @@ data_callback(const char *key, const char *value)
333334
char *line;
334335
asprintf(&line, OPAL_LIBDIR_FLAG"%s",
335336
options_data[parse_options_idx].path_libdir);
336-
opal_argv_append_nosize(&options_data[parse_options_idx].link_flags, line);
337+
opal_argv_prepend_nosize(&options_data[parse_options_idx].link_flags, line);
337338
free(line);
338339
}
339340
} else if (0 == strcmp(key, "opalincludedir")) {

0 commit comments

Comments
 (0)