Skip to content

Commit 94bed42

Browse files
authored
Merge pull request #10767 from bwbarrett/bugfix/dependencies-in-component-build-mode
Abort configure if static component depends on dso common
2 parents 1e68f90 + 2f5ed7b commit 94bed42

File tree

10 files changed

+137
-23
lines changed

10 files changed

+137
-23
lines changed

config/oac_literal.m4

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
dnl -*- autoconf -*-
2+
dnl
3+
dnl Copyright (c) 2022 Amazon.com, Inc. or its affiliates. All Rights reserved.
4+
dnl $COPYRIGHT$
5+
dnl
6+
dnl Additional copyrights may follow
7+
8+
dnl OAC_ASSERT_LITERAL: Assert if first argument is not an Autoconf literal
9+
dnl
10+
dnl 1 -> Variable which must be a literal
11+
dnl 2 -> Argument reference string (usually an integer argument number)
12+
dnl
13+
dnl Assert that the first argument is a literal (in the Autoconf sense
14+
dnl of the word) Second argument is the argument number (ie, a bare
15+
dnl number) to make the error message easier to parse.
16+
AC_DEFUN([OAC_ASSERT_LITERAL],
17+
[AS_LITERAL_IF([$1], [], [m4_fatal([argument $2 ($1) must be a literal])])])dnl

config/opal_check_compiler_version.m4

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ AC_DEFUN([OPAL_CHECK_COMPILER_VERSION_ID],
2727

2828

2929
AC_DEFUN([OPAL_CHECK_COMPILER], [
30-
AS_LITERAL_IF([$1], [],
31-
[m4_fatal([OPAL_CHECK_COMPILER argument must be a literal])])
30+
OAC_ASSERT_LITERAL([$1], [1])dnl
3231
lower=m4_tolower([$1])
3332
AC_CACHE_CHECK([for compiler $lower], [opal_cv_compiler_$1],
3433
[

config/opal_mca.m4

Lines changed: 84 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ dnl Copyright (c) 2004-2005 The Regents of the University of California.
1212
dnl All rights reserved.
1313
dnl Copyright (c) 2010-2021 Cisco Systems, Inc. All rights reserved
1414
dnl Copyright (c) 2013-2017 Intel, Inc. All rights reserved.
15-
dnl Copyright (c) 2018-2021 Amazon.com, Inc. or its affiliates.
16-
dnl All Rights reserved.
15+
dnl Copyright (c) 2018-2022 Amazon.com, Inc. or its affiliates. All Rights reserved.
1716
dnl Copyright (c) 2021 Triad National Security, LLC. All rights
1817
dnl reserved.
1918
dnl $COPYRIGHT$
@@ -604,9 +603,7 @@ AC_DEFUN([MCA_CONFIGURE_M4_CONFIG_COMPONENT],[
604603
MCA_COMPONENT_BUILD_CHECK($1, $2, $3, [should_build=$8], [should_build=0])
605604
# Allow the component to override the build mode if it really wants to.
606605
# It is, of course, free to end up calling MCA_COMPONENT_COMPILE_MODE
607-
m4_ifdef([MCA_$1_$2_$3_COMPILE_MODE],
608-
[MCA_$1_$2_$3_COMPILE_MODE($1, $2, $3, compile_mode)],
609-
[MCA_COMPONENT_COMPILE_MODE($1, $2, $3, compile_mode)])
606+
MCA_COMPONENT_COMPILE_MODE([$1], [$2], [$3], [compile_mode])
610607
611608
# try to configure the component
612609
m4_ifdef([MCA_$1_$2_$3_CONFIG],
@@ -706,10 +703,52 @@ AC_DEFUN([MCA_CONFIGURE_ALL_CONFIG_COMPONENTS],[
706703
# MCA_COMPONENT_COMPILE_MODE(project_name (1), framework_name (2),
707704
# component_name (3), compile_mode_variable (4))
708705
# -------------------------------------------------------------------------
709-
# set compile_mode_variable to the compile mode for the given component
706+
# set compile_mode_variable to the compile mode for the given component.
707+
# this macro will only evaluate the build mode once per configure, returning
708+
# the cached value for subsequent tests. The string is not stored in a cache
709+
# variable (ie .*_cv_.*) because cache variables would not be invalidated
710+
# based on changes to --enable-mca-dso or --enable-mca-static.
710711
#
711712
# NOTE: component_name may not be determined until runtime....
712713
AC_DEFUN([MCA_COMPONENT_COMPILE_MODE],[
714+
OAC_ASSERT_LITERAL([$1], [1])dnl
715+
OAC_ASSERT_LITERAL([$2], [2])dnl
716+
717+
AS_VAR_PUSHDEF([compile_mode_cv], [$1_$2_$3_compile_mode])dnl
718+
AS_VAR_SET_IF([compile_mode_cv],
719+
[],
720+
[AS_LITERAL_IF([$3],
721+
[m4_ifdef([MCA_$1_$2_$3_COMPILE_MODE],
722+
[dnl We introduced caching of this check after setting the compile
723+
dnl mode by the substitute macro was common, and there was not a
724+
dnl polymorphic variable assumption in all those macros, so we use
725+
dnl a temporary with a fixed name.
726+
OPAL_VAR_SCOPE_PUSH([component_compile_mode_tmp])
727+
MCA_$1_$2_$3_COMPILE_MODE([$1], [$2], [$3], [component_compile_mode_tmp])
728+
AS_VAR_COPY([compile_mode_cv], [$component_compile_mode_tmp])
729+
OPAL_VAR_SCOPE_POP],
730+
[MCA_COMPONENT_COMPILE_MODE_INTERNAL([$1], [$2], [$3], [compile_mode_cv])])],
731+
[MCA_COMPONENT_COMPILE_MODE_INTERNAL([$1], [$2], [$3], [compile_mode_cv])])])
732+
AS_VAR_COPY([$4], [compile_mode_cv])
733+
AS_VAR_POPDEF([compile_mode_cv])dnl
734+
])
735+
736+
# MCA_COMPONENT_COMPILE_MODE_INTERNAL(project_name (1), framework_name (2),
737+
# component_name (3), compile_mode_variable (4))
738+
# -------------------------------------------------------------------------
739+
# Determine compile mode of the given component. Prefer a static
740+
# build by default. Users can customize build mode by influencing the
741+
# component, framework, or all-up build flags. This function starts
742+
# at the most specific (component) and works its way out, looking for
743+
# a set option.
744+
#
745+
# Components can avoid calling this function by defining a macro
746+
# MCA_<project>_<framework>_<component>_COMPILE_MODE.
747+
#
748+
# NOTE: component_name may not be determined until runtime....
749+
AC_DEFUN([MCA_COMPONENT_COMPILE_MODE_INTERNAL], [
750+
OPAL_VAR_SCOPE_PUSH([compile_mode_internal_tmp SHARED_FRAMEWORK SHARED_COMPONENT STATIC_FRAMEWORK STATIC_COMPONENT])
751+
713752
SHARED_FRAMEWORK="$DSO_$2"
714753
AS_VAR_COPY([SHARED_COMPONENT], [DSO_$2_$3])
715754
@@ -720,27 +759,31 @@ AC_DEFUN([MCA_COMPONENT_COMPILE_MODE],[
720759
# there is a tie (either neither or both specified), prefer
721760
# static.
722761
if test "$STATIC_COMPONENT" = "1"; then
723-
$4=static
762+
compile_mode_internal_tmp=static
724763
elif test "$SHARED_COMPONENT" = "1"; then
725-
$4=dso
764+
compile_mode_internal_tmp=dso
726765
elif test "$STATIC_FRAMEWORK" = "1"; then
727-
$4=static
766+
compile_mode_internal_tmp=static
728767
elif test "$SHARED_FRAMEWORK" = "1"; then
729-
$4=dso
768+
compile_mode_internal_tmp=dso
730769
elif test "$STATIC_all" = "1"; then
731-
$4=static
770+
compile_mode_internal_tmp=static
732771
elif test "$DSO_all" = "1"; then
733-
$4=dso
772+
compile_mode_internal_tmp=dso
734773
else
735-
$4=static
774+
compile_mode_internal_tmp=static
736775
fi
737776
777+
AS_VAR_SET([$4], [$compile_mode_internal_tmp])
778+
738779
AC_MSG_CHECKING([for MCA component $2:$3 compile mode])
739780
if test "$DIRECT_$2" = "$3" ; then
740-
AC_MSG_RESULT([$$4 - direct])
781+
AC_MSG_RESULT([$compile_mode_internal_tmp - direct])
741782
else
742-
AC_MSG_RESULT([$$4])
783+
AC_MSG_RESULT([$compile_mode_internal_tmp])
743784
fi
785+
786+
OPAL_VAR_SCOPE_POP
744787
])
745788

746789
# OPAL_MCA_STRIP_LAFILES(output_variable(1),
@@ -990,3 +1033,29 @@ AC_DEFUN([OPAL_MCA_MAKE_DIR_LIST],[
9901033
done
9911034
AC_SUBST($1)
9921035
])
1036+
1037+
1038+
# OPAL_MCA_CHECK_DEPENDENCY(check project, check framework, check component,
1039+
# dependent project, dependent framework, dependent component)
1040+
# --------------------------------------------------------------------------
1041+
# Enforce that the check component does not introduce a dependency from its
1042+
# project library (ie libmpi.so or libopen-pal.so) to another component
1043+
# (ie, a common_*.so). This can happen if the check component is set to
1044+
# build static and the common library is set to build dso. If this situation
1045+
# is detected, print an error and abort configure.
1046+
AC_DEFUN([OPAL_MCA_CHECK_DEPENDENCY],
1047+
[
1048+
OPAL_VAR_SCOPE_PUSH([component_compile_mode dependency_compile_mode])
1049+
1050+
MCA_COMPONENT_COMPILE_MODE([$1], [$2], [$3], [component_compile_mode])
1051+
MCA_COMPONENT_COMPILE_MODE([$4], [$5], [$6], [dependency_compile_mode])
1052+
1053+
AS_IF([test "${component_compile_mode}" = "static" -a "${dependency_compile_mode}" = "dso"],
1054+
[AC_MSG_ERROR([Component $2:$3 is set to build as a
1055+
static component, but its dependency $5:$6 is set to build as
1056+
a dynamic component. This configuration is not supported. Please
1057+
either build $5:$6 as a static component or build $2:$3 as a dynamic
1058+
component.])])
1059+
1060+
OPAL_VAR_SCOPE_POP
1061+
])

ompi/mca/coll/han/Makefile.am

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# Copyright (c) 2018-2020 The University of Tennessee and The University
33
# of Tennessee Research Foundation. All rights
44
# reserved.
5+
# Copyright (c) 2022 Amazon.com, Inc. or its affiliates. All Rights reserved.
56
# $COPYRIGHT$
67
#
78
# Additional copyrights may follow
@@ -41,9 +42,6 @@ else
4142
component_noinst += libmca_coll_han.la
4243
endif
4344

44-
# See ompi/mca/btl/sm/Makefile.am for an explanation of
45-
# libmca_common_sm.la.
46-
4745
mcacomponentdir = $(ompilibdir)
4846
mcacomponent_LTLIBRARIES = $(component_install)
4947
mca_coll_han_la_SOURCES = $(sources)

ompi/mca/coll/sm/configure.m4

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# -*- autoconf -*-
2+
#
3+
# Copyright (c) 2022 Amazon.com, Inc. or its affiliates. All Rights reserved.
4+
# $COPYRIGHT$
5+
#
6+
# Additional copyrights may follow
7+
#
8+
# $HEADER$
9+
#
10+
11+
AC_DEFUN([MCA_ompi_coll_sm_CONFIG],[
12+
AC_CONFIG_FILES([ompi/mca/coll/sm/Makefile])
13+
14+
OPAL_MCA_CHECK_DEPENDENCY([ompi], [coll], [sm], [opal], [common], [sm])
15+
16+
$1
17+
])dnl

ompi/mca/mtl/ofi/configure.m4

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ AC_DEFUN([MCA_ompi_mtl_ofi_CONFIG],[
4848
[],
4949
[mtl_ofi_happy=0])])])
5050
51+
AS_IF([test ${mtl_ofi_happy} -eq 1],
52+
[OPAL_MCA_CHECK_DEPENDENCY([opal], [btl], [ofi], [opal], [common], [ofi])])
53+
5154
AS_IF([test ${mtl_ofi_happy} -eq 1],
5255
[$1],
5356
[AS_IF([test -n "${with_ofi}" -a "${with_ofi}" != "no"],

ompi/mca/osc/ucx/configure.m4

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# -*- shell-script -*-
22
#
33
# Copyright (C) Mellanox Technologies Ltd. 2001-2017. ALL RIGHTS RESERVED.
4+
# Copyright (c) 2022 Amazon.com, Inc. or its affiliates. All Rights reserved.
45
# $COPYRIGHT$
56
#
67
# Additional copyrights may follow
@@ -25,6 +26,9 @@ AC_DEFUN([MCA_ompi_osc_ucx_CONFIG],[
2526
[osc_ucx_happy="yes"],
2627
[osc_ucx_happy="no"])
2728

29+
AS_IF([test "${osc_ucx_happy}" = "yes"],
30+
[OPAL_MCA_CHECK_DEPENDENCY([ompi], [osc], [ucx], [opal], [common], [ucx])])
31+
2832
AS_IF([test "$osc_ucx_happy" = "yes"],
2933
[$1],
3034
[$2])

ompi/mca/pml/ucx/configure.m4

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#
22
# Copyright (C) Mellanox Technologies Ltd. 2001-2015. ALL RIGHTS RESERVED.
3+
# Copyright (c) 2022 Amazon.com, Inc. or its affiliates. All Rights reserved.
34
# $COPYRIGHT$
45
#
56
# Additional copyrights may follow
@@ -19,6 +20,9 @@ AC_DEFUN([MCA_ompi_pml_ucx_CONFIG], [
1920
[pml_ucx_happy="yes"],
2021
[pml_ucx_happy="no"])
2122
23+
AS_IF([test "${pml_ucx_happy}" = "yes"],
24+
[OPAL_MCA_CHECK_DEPENDENCY([ompi], [pml], [ucx], [opal], [common], [ucx])])
25+
2226
AS_IF([test "$pml_ucx_happy" = "yes"],
2327
[$1],
2428
[$2])

opal/mca/btl/ofi/configure.m4

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
# Copyright (c) 2011-2018 Los Alamos National Security, LLC.
1616
# All rights reserved.
1717
# Copyright (c) 2018 Intel, inc. All rights reserved
18-
#
1918
# Copyright (c) 2022 Amazon.com, Inc. or its affiliates. All Rights reserved.
2019
# $COPYRIGHT$
2120
#
@@ -45,6 +44,9 @@ AC_DEFUN([MCA_opal_btl_ofi_CONFIG],[
4544
[#include <rdma/fabric.h>])
4645
CPPFLAGS=${CPPFLAGS_save}])
4746
47+
AS_IF([test ${btl_ofi_happy} -eq 1],
48+
[OPAL_MCA_CHECK_DEPENDENCY([opal], [btl], [ofi], [opal], [common], [ofi])])
49+
4850
AS_IF([test ${btl_ofi_happy} -eq 1],
4951
[$1],
5052
[AS_IF([test -n "${with_ofi}" -a "${with_ofi}" != "no"],

opal/mca/btl/smcuda/configure.m4

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
# reserved.
66
# Copyright (c) 2009-2010 Cisco Systems, Inc. All rights reserved.
77
# Copyright (c) 2012-2015 NVIDIA Corporation. All rights reserved.
8+
# Copyright (c) 2022 Amazon.com, Inc. or its affiliates. All Rights reserved.
89
# $COPYRIGHT$
910
#
1011
# Additional copyrights may follow
@@ -23,7 +24,7 @@ AC_DEFUN([MCA_opal_btl_smcuda_CONFIG],[
2324

2425
# Only build if CUDA support is available
2526
AS_IF([test "x$CUDA_SUPPORT" = "x1"],
26-
[$1],
27+
[$1
28+
OPAL_MCA_CHECK_DEPENDENCY([opal], [btl], [smcuda], [opal], [common], [sm])],
2729
[$2])
28-
2930
])dnl

0 commit comments

Comments
 (0)