Skip to content
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

Add logic in configure.ac to check for flex and fail if not found #1394

Merged
merged 2 commits into from
May 11, 2024

Conversation

jennfshr
Copy link
Collaborator

@jennfshr jennfshr commented May 8, 2024

I encountered an issue when trying to build LDMS on AlmaLinux8 where flex wasn't installed on the system. It doesn't fail at configure, and the error during compilation is esoteric.

@nichamon @bschwal @baallan

The issue:

there’s a problem when you run configure without flex support, it configures fine, but fails with some esoteric error:

make[6]: Entering directory '/home/jkgreen/Source/ovis/build/lib/src/ovis_json'
  CC       ovis_json_test-ovis_json_test.o
  CC       ovis_json.lo
: -o ovis_json_lexer.c ../../../../lib/src/ovis_json/ovis_json_lexer.l
  CC       ovis_json_lexer.lo
gcc: error: ovis_json_lexer.c: No such file or directory
gcc: fatal error: no input files

The error output suggests a bug or incompatibility in bison or yacc, when really, it just needs a flex package to work. Apparently, this has bit more than one of us, so I thought I'd supply a quick patch.

Here's a reproducer:

#!/bin/bash
[[ -d OVIS ]] && rm -Rf OVIS

## Reproducer for issue with flex not being on the system

git clone -b OVIS-4 https://github.com/ovis-hpc/ovis.git OVIS
cd ovis/
cd ../OVIS/
./autogen.sh || echo "Autogen failed"
mkdir build
cd build
../configure --prefix=/home/jkgreen/OVIS/build/4

if [[ $? -ne 0 ]] ; then
  echo "configure failed"
  exit -1 
fi

make || echo "configure failed"  ### this fails due to not having a lexer generator
cd ../../
rm -Rf OVIS

### TRY THE PATCH

git clone -b OVIS-4 https://github.com/ovis-hpc/ovis.git OVIS
cd OVIS

## Apply the patch to test it
cat <<EOF >flex-configure.ac-fix.patch
diff --git a/configure.ac b/configure.ac
index 5c1846d7..4562eb8b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -43,6 +43,11 @@ dnl if LEX is not available, the configure still won't fail
 AC_PROG_LEX
 AC_PROG_LN_S
 
+AC_PATH_PROG(FLEX, flex)
+if test -z "\$FLEX"; then
+   AC_MSG_ERROR([You need the 'flex' lexer generator to compile LDMS])
+fi
+
 AC_ARG_VAR([BISON], [bison command])
 AC_CHECK_PROG([BISON], [bison -y], [bison -y], [no])
 AS_IF([test "x\$BISON" = "xno"], [AC_MSG_ERROR([bison not found])])

EOF

[[ -f flex-configure.ac-fix.patch ]] && git apply -v flex-configure.ac-fix.patch
if [[ $? -ne 0 ]] ; then
  echo "git apply patch fails... "
fi

./autogen.sh || echo "Autogen failed"
mkdir build
cd build

../configure --prefix=/home/jkgreen/OVIS/build/4
if [[ $? -ne 0 ]] ; then
  echo "configure failed"
  exit -1 
fi

make ||  echo "make failed"

… error. This patch fixes it to fail at configure
@tom95858
Copy link
Collaborator

tom95858 commented May 9, 2024

Hi @jennfshr, could you please remove the trailing spaces that were added to configure.ac. This causes one of the build checks to fail.

@jennfshr
Copy link
Collaborator Author

jennfshr commented May 9, 2024

Hi @jennfshr, could you please remove the trailing spaces that were added to configure.ac. This causes one of the build checks to fail.

@tom95858 I think this will satisfy the space check:

[jkgreen@441653a5bb21 OVIS]$ git diff origin/OVIS-4 > /tmp/diff
[jkgreen@441653a5bb21 OVIS]$ set -e 
[jkgreen@441653a5bb21 OVIS]$   if grep '^+.*[[:space:]]$' /tmp/diff ; then
>     echo "---------------------------------------"
>     echo "Pull request contains trailing spaces"
>     exit -1
>   else
>     echo "---------------------------------------"
>     echo "OK."
>     exit 0
>   fi
---------------------------------------
OK.
logout

@tom95858
Copy link
Collaborator

@jennfshr we already have a check for trailing spaces and this check runs on the pull request when it is submitted. However, since your are not yet a developer on the project, I have to manually authorize the pull request tests. When I did that particular pull request test failed and I let you know. I will add you to the developer list and this problem should go away.

@tom95858 tom95858 merged commit 01ba8e5 into ovis-hpc:OVIS-4 May 11, 2024
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants