Skip to content

Commit

Permalink
Do not hardcode GCC/g++ in shell scripts
Browse files Browse the repository at this point in the history
BSD systems won't alias gcc to clang.
  • Loading branch information
tautschnig committed Nov 21, 2023
1 parent b688885 commit 7b06901
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/bsd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
echo "Print ccache stats"
ccache -s
echo "Checking completeness of help output"
scripts/check_help.sh
scripts/check_help.sh clang++
echo "Run unit tests"
gmake -C unit test
# gmake -C jbmc/unit test
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pull-request-checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jobs:
- name: Print ccache stats
run: ccache -s
- name: Checking completeness of help output
run: scripts/check_help.sh
run: scripts/check_help.sh g++
- name: Run unit tests
run: |
make -C unit test IPASIR=$PWD/riss.git/riss
Expand Down Expand Up @@ -247,7 +247,7 @@ jobs:
- name: Print ccache stats
run: ccache -s
- name: Checking completeness of help output
run: scripts/check_help.sh build/bin
run: scripts/check_help.sh /usr/bin/g++ build/bin
- name: Check if package building works
run: |
cd build
Expand Down
7 changes: 5 additions & 2 deletions scripts/bash-autocomplete/extract_switches.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,18 @@

set -e

CXX=$1
shift

# make sure we execute the remainder in the directory containing this script
cd `dirname $0`

echo "Compiling the helper file to extract the raw list of parameters from cbmc"
g++ -E -dM -std=c++17 -I../../src ../../src/cbmc/cbmc_parse_options.cpp -o macros.c
$CXX -E -dM -std=c++17 -I../../src ../../src/cbmc/cbmc_parse_options.cpp -o macros.c
echo CBMC_OPTIONS >> macros.c

echo "Converting the raw parameter list to the format required by autocomplete scripts"
rawstring="`gcc -E -P -w macros.c` \"?h(help)\""
rawstring="`$CXX -E -P -w macros.c` \"?h(help)\""
rm macros.c

#now the main bit, convert from raw format to a proper list of switches
Expand Down
7 changes: 5 additions & 2 deletions scripts/check_help.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

set -e

CXX=$1
shift

# if a command-line argument is provided, use it as a path to built binaries
# (CMake-style build); otherwise assume we use Makefile-based in-tree build
if [ $# -eq 1 ] ; then
Expand Down Expand Up @@ -33,10 +36,10 @@ for t in \
tool_name=$(basename $t)
opt_name=$(echo $tool_name | tr 'a-z-' 'A-Z_')
echo "Extracting the raw list of parameters from $tool_name"
g++ -E -dM -std=c++17 -I../src -I../jbmc/src $t/*_parse_options.cpp -o macros.c
$CXX -E -dM -std=c++17 -I../src -I../jbmc/src $t/*_parse_options.cpp -o macros.c
# goto-analyzer partly uses the spelling "analyser" within the code base
echo ${opt_name}_OPTIONS | sed 's/GOTO_ANALYZER/GOTO_ANALYSER/' >> macros.c
rawstring="`gcc -E -P -w macros.c` \"?h(help)\""
rawstring="`$CXX -E -P -w macros.c` \"?h(help)\""
rm macros.c

# now the main bit, convert from raw format to a proper list of switches
Expand Down
2 changes: 1 addition & 1 deletion src/cbmc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ endif()
# bash completion
if(NOT WIN32)
add_custom_command(OUTPUT "${CBMC_ROOT_DIR}/scripts/bash-autocomplete/cbmc.sh"
COMMAND "${CBMC_ROOT_DIR}/scripts/bash-autocomplete/extract_switches.sh"
COMMAND "${CBMC_ROOT_DIR}/scripts/bash-autocomplete/extract_switches.sh" "${CMAKE_CXX_COMPILER}"
DEPENDS $<TARGET_FILE:cbmc>
)
add_custom_target(cbmc.sh ALL
Expand Down

0 comments on commit 7b06901

Please sign in to comment.