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

cd-hit: add osx-arm64 build #52061

Merged
merged 1 commit into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions recipes/cd-hit/build.sh
Original file line number Diff line number Diff line change
@@ -1,26 +1,28 @@
#!/bin/sh
#!/bin/bash

export CFLAGS="-I$PREFIX/include"
export CPPFLAGS="-I$PREFIX/include"
export CXXFLAGS="-I$PREFIX/include"
export LDFLAGS="-L$PREFIX/lib"
mkdir -p $PREFIX/bin

export CFLAGS="${CFLAGS} -O3"
export CPPFLAGS="${CPPFLAGS} -I$PREFIX/include"
export CXXFLAGS="${CXXFLAGS} -O3 -I$PREFIX/include"
export LDFLAGS="${LDFLAGS} -L$PREFIX/lib"
export CPATH=${PREFIX}/include
Comment on lines +5 to 9
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Improve environment variable handling.

The compiler flags setup looks good, but there are two improvements to consider:

  1. CPATH should be exported like other variables
  2. Variables should be quoted to handle paths with spaces
-export CFLAGS="${CFLAGS} -O3"
-export CPPFLAGS="${CPPFLAGS} -I$PREFIX/include"
-export CXXFLAGS="${CXXFLAGS} -O3 -I$PREFIX/include"
-export LDFLAGS="${LDFLAGS} -L$PREFIX/lib"
-export CPATH=${PREFIX}/include
+export CFLAGS="${CFLAGS} -O3"
+export CPPFLAGS="${CPPFLAGS} -I\"${PREFIX}/include\""
+export CXXFLAGS="${CXXFLAGS} -O3 -I\"${PREFIX}/include\""
+export LDFLAGS="${LDFLAGS} -L\"${PREFIX}/lib\""
+export CPATH="${PREFIX}/include"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
export CFLAGS="${CFLAGS} -O3"
export CPPFLAGS="${CPPFLAGS} -I$PREFIX/include"
export CXXFLAGS="${CXXFLAGS} -O3 -I$PREFIX/include"
export LDFLAGS="${LDFLAGS} -L$PREFIX/lib"
export CPATH=${PREFIX}/include
export CFLAGS="${CFLAGS} -O3"
export CPPFLAGS="${CPPFLAGS} -I\"${PREFIX}/include\""
export CXXFLAGS="${CXXFLAGS} -O3 -I\"${PREFIX}/include\""
export LDFLAGS="${LDFLAGS} -L\"${PREFIX}/lib\""
export CPATH="${PREFIX}/include"


sed -i.bak 's/^CC =$//g' Makefile
sed -i.bak 's/^#LDFLAGS.*//g' Makefile

rm -rf *.bak

if [[ "$OSTYPE" == "darwin"* ]]; then
#Lines below is commented out until fix provided for OPENMP support on OS X for this program

CCFLAGS="$CCFLAGS -Wl,-rpath ${PREFIX}/lib -L${PREFIX}/lib -I${PREFIX}/include -fopenmp"
sed -i.bak 's/CCFLAGS = -fopenmp/CCFLAGS += -fopenmp/g' Makefile
rm -rf *.bak
LDFLAGS="$LDFLAGS -stdlib=libc++"

make CC=$CXX openmp=no MAX_SEQ=1000000
else
make CC=$GXX MAX_SEQ=1000000
fi

mkdir -p $PREFIX/bin
make install PREFIX=$PREFIX/bin

make install PREFIX="$PREFIX/bin"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix PREFIX path and add error handling.

The PREFIX should point to the root prefix directory, not directly to the bin directory. Also, add error checking for the installation step.

-make install PREFIX="$PREFIX/bin"
+if ! make install PREFIX="$PREFIX"; then
+    echo "Error: Installation failed"
+    exit 1
+fi
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
make install PREFIX="$PREFIX/bin"
if ! make install PREFIX="$PREFIX"; then
echo "Error: Installation failed"
exit 1
fi

Loading