-
Notifications
You must be signed in to change notification settings - Fork 867
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
Passing CFLAGS down to 3rd-party/ broken due to *_CFLAGS_BEFORE_PICKY #12895
Comments
I did some tests and the flags appear to be working as intended. Not clear that I still need to use them in all those places,but there are a couple that definitely need it. The PRRTE one was clearly a typo, so I fixed that one. However, any CFLAGS you provide should flow through - we just don't include all the picky compiler flags we add ourselves. |
I'm using the release tarball 5.0.5. I have a reproducer to make my point and prove that CFLAGS are not being passed down. #!/bin/bash
PREFIX=/tmp/install
BUILDDIR=/tmp/my_private_directory
mkdir -p $BUILDDIR && cd $BUILDDIR
curl -O https://download.open-mpi.org/release/open-mpi/v5.0/openmpi-5.0.5.tar.gz
tar xf openmpi-5.0.5.tar.gz
cd openmpi-5.0.5
export CFLAGS=-ffile-prefix-map=$BUILDDIR=OPENMPI
./configure \
--prefix=$PREFIX \
--with-pmix=internal \
--with-prrte=internal \
--with-libevent=internal \
--with-hwloc=internal \
--without-ofi \
--without-ucx \
--without-psm2 \
--without-cuda \
--without-rocm \
--disable-dlopen \
--disable-oshmem \
--disable-static \
--disable-opencl \
--disable-libxml2 \
--disable-libompitrace \
--enable-mpi-fortran=mpifh \
--disable-dependency-tracking
cflags="s|\s*${CFLAGS}\s*| |g"
builddir="s|$BUILDDIR|OPENMPI|g"
makefiles+=(ompi/tools/ompi_info/Makefile)
makefiles+=(oshmem/tools/oshmem_info/Makefile)
makefiles+=(3rd-party/openpmix/src/tools/*/Makefile)
makefiles+=(3rd-party/prrte/src/tools/*/Makefile)
for filename in ${makefiles[@]}; do
sed -i.orig "/-D.*_BUILD_CFLAGS=/$cflags" $filename
sed -i.orig "/-D.*_BUILD_CPPFLAGS=/$builddir" $filename
sed -i.orig "/-D.*_BUILD_LIBS=/$builddir" $filename
done
headers+=(opal/include/opal_config.h)
headers+=(3rd-party/openpmix/src/include/pmix_config.h)
headers+=(3rd-party/prrte/src/include/prte_config.h)
for filename in ${headers[@]}; do
sed -i.orig "$cflags" $filename
sed -i.orig "$builddir" $filename
done
make -j $(nproc)
grep "$PWD" $(find . -name '*.o') This script is setting grep: ./3rd-party/prrte/src/mca/rmaps/rank_file/.libs/rmaps_rank_file.o: binary file matches
grep: ./3rd-party/prrte/src/util/hostfile/.libs/hostfile.o: binary file matches and that simply means that these object files were compiled without using the @rhc54 Maybe the whole problem is caused by the typo you fixed? |
No, that's not enough.
|
After running the script above, I performed the following two tests
Note the presence of Next, try the following:
Note the absence of Therefore, my original complaint stands, at least for the code in the latest release tarball. |
I think the first thing to check is whether or not the individual projects (i.e., standing on their own) are handling things correctly so folks can see if it is the OMPI-project integration that is the problem here. OMPI does, after all, process its own configure (including handling "picky" compiler flags) prior to passing it all down to us. |
@rhc54 I think this is a problem in the individual projects, and it is simply a missing
diff --git a/config/pmix_setup_cc.m4 b/config/pmix_setup_cc.m4
index 634b96bd..26767e2b 100644
--- a/config/pmix_setup_cc.m4
+++ b/config/pmix_setup_cc.m4
@@ -378,6 +378,7 @@ AC_DEFUN([PMIX_SETUP_CC],[
PMIX_ENSURE_CONTAINS_OPTFLAGS("$PMIX_CFLAGS_BEFORE_PICKY")
PMIX_CFLAGS_BEFORE_PICKY="$co_result"
+ AC_SUBST([PMIX_CFLAGS_BEFORE_PICKY])
AC_MSG_CHECKING([for C optimization flags])
PMIX_ENSURE_CONTAINS_OPTFLAGS(["$CFLAGS"])
diff --git a/config/prte_setup_cc.m4 b/config/prte_setup_cc.m4
index aa28a673ea..083a61adfa 100644
--- a/config/prte_setup_cc.m4
+++ b/config/prte_setup_cc.m4
@@ -371,6 +371,7 @@ AC_DEFUN([PRTE_SETUP_CC],[
PRTE_ENSURE_CONTAINS_OPTFLAGS("$PRTE_CFLAGS_BEFORE_PICKY")
PRTE_CFLAGS_BEFORE_PICKY="$co_result"
+ AC_SUBST([PRTE_CFLAGS_BEFORE_PICKY])
AC_MSG_CHECKING([for C optimization flags])
PRTE_ENSURE_CONTAINS_OPTFLAGS(["$CFLAGS"])
diff --git a/src/mca/rmaps/rank_file/Makefile.am b/src/mca/rmaps/rank_file/Makefile.am
index 1e6b2166dd..f628074299 100644
--- a/src/mca/rmaps/rank_file/Makefile.am
+++ b/src/mca/rmaps/rank_file/Makefile.am
@@ -28,7 +28,7 @@ AM_LFLAGS = -Pprte_rmaps_rank_file_
LEX_OUTPUT_ROOT = lex.prte_rmaps_rank_file_
dist_prtedata_DATA = help-rmaps_rank_file.txt
# we do NOT want picky compilers down here due to flex
-CFLAGS = $(PMIX_CFLAGS_BEFORE_PICKY)
+CFLAGS = $(PRTE_CFLAGS_BEFORE_PICKY)
sources = \
rmaps_rank_file.c \
diff --git a/src/util/hostfile/Makefile.am b/src/util/hostfile/Makefile.am
index 20c5fd80a0..8836ec3e72 100644
--- a/src/util/hostfile/Makefile.am
+++ b/src/util/hostfile/Makefile.am
@@ -25,7 +25,7 @@
AM_LFLAGS = -Pprte_util_hostfile_
LEX_OUTPUT_ROOT = lex.prte_util_hostfile_
# we do NOT want picky compilers down here
-CFLAGS = $(PMIX_CFLAGS_BEFORE_PICKY)
+CFLAGS = $(PRTE_CFLAGS_BEFORE_PICKY)
noinst_LTLIBRARIES = libprrteutilhostfile.la
EDIT: the ompi repo is also missing an diff --git a/config/opal_setup_cc.m4 b/config/opal_setup_cc.m4
index 70b8c6f133..0ca32d8688 100644
--- a/config/opal_setup_cc.m4
+++ b/config/opal_setup_cc.m4
@@ -412,6 +412,7 @@ AC_DEFUN([OPAL_SETUP_CC],[
OPAL_ENSURE_CONTAINS_OPTFLAGS("$OPAL_CFLAGS_BEFORE_PICKY")
OPAL_CFLAGS_BEFORE_PICKY="$co_result"
+ AC_SUBST([OPAL_CFLAGS_BEFORE_PICKY])
AC_MSG_CHECKING([for C optimization flags])
OPAL_ENSURE_CONTAINS_OPTFLAGS(["$CFLAGS"]) |
I'll take a look, but am somewhat suspicious - as I noted earlier, I verified that the Makefile is doing the right thing (in terms of substituting the correct "before picky" cflags) as it stands today. Not sure when I'll get to it - need to finish the current punch list first. |
@rhc54 If it is quick to answer, how are you doing your testing? Without AC_SUBST, how the @wenduwan Could you please add this issue to the list of things to address before the next release? |
I simply remove the "before picky" entry from the Makefile and verify that compilation fails with picky enabled. Put that line back and it all works again. So it clearly is being set. Note, however, that it only gets set if you either specifically ask for devel-check, or you are in a Git checkout and have enabled debug. Otherwise, it is a noop. Note that wenduwan is no longer with the project. I somewhat doubt anything will be done for the next release as release candidates for PMIx and PRRTE are already out, there is a short time fuse, and this isn't a critical issue impacting users. |
That is of course expected. When you put the line back, it is equivalent to doing
I'm personally in no hurry and under no pressure for this fix. However, in a more general consideration, missing compiler flags could potentially ease undisclosed exploitable security issues. |
I remain suspicious because
Ah yes - the usual boogey-man warning 😄 Appropriate for Halloween over here! Seriously, I'll get to it when time permits. A low priority compared to other things. |
I'm trying to build relocatable installations able to install and run in Python environments. As an additional feature, I'm trying to make the builds reproducible, which eventually requires removing hardwired paths to the source or build directory. This can be (partially) accomplished with compiler flags to handle things like
__FILE__
. But then I discovered that not all sources in3rd-party/
are compiled with the flags I'm seeing viaCFLAGS
.I guess the best way to notice the problem is doing a out-of-source configure with internal libraries. For this test I'm using the sources from the 5.0.5 tarball.
and after configure is done, within the same BUILD directory, run
BTW, note that under
prrte
, bothPRTE_CFLAGS_BEFORE_PICKY
andPMIX_CFLAGS_BEFORE_PICKY
are used. I suspect the thePMIX_CFLAGS_BEFORE_PICKY
one is wrong, the other should be used.As a workaround, for the v5.0.x tarball, I'm "hotfixing" the unpacked sources the following way:
After this patching, everything works as expected. This is of course not the proper fix. My only point is to prove that the generated Makefile files are missing the assignments
(PMIX|PRTE)_CFLAGS_BEFORE_PICKY = ...
.I'm not an autotools expert. Maybe the various Makefile.am with lines like:are missing the following linesuch that configure can do its magic?NO, this does not seem to make it 😞 .cc @rhc54
The text was updated successfully, but these errors were encountered: