Skip to content

Commit cb7bb31

Browse files
committed
fixing macOS issues and envs
1 parent d23551b commit cb7bb31

3 files changed

Lines changed: 36 additions & 27 deletions

File tree

build.sh

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs=8
1919
#########
2020
# Variables and Paths
2121
########
22-
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
22+
SCRIPT_DIR=$( cd -- "$( dirname -- "$0" )" &> /dev/null && pwd )
2323
SVFHOME="${SCRIPT_DIR}"
2424
sysOS=$(uname -s)
2525
arch=$(uname -m)
@@ -174,7 +174,7 @@ function build_z3_from_source {
174174
mkdir "$Z3Home"
175175
echo "Downloading Z3 source..."
176176
if ! generic_download_file "$SourceZ3" z3.zip; then
177-
exit 1
177+
exit 1
178178
fi
179179
check_unzip
180180
echo "Unzipping Z3 source..."
@@ -309,7 +309,7 @@ if [[ -z "${LLVM_DIR:-}" || ! -d "$LLVM_DIR" ]]; then
309309
# check whether llvm is installed
310310
if [ $? -eq 0 ]; then
311311
echo "LLVM binary installation completed."
312-
export LLVM_DIR="$(brew --prefix llvm)/@${MajorLLVMVer}/bin"
312+
export LLVM_DIR="$(brew --prefix llvm)@${MajorLLVMVer}/lib/cmake/llvm"
313313
else
314314
echo "LLVM binary installation failed."
315315
exit 1
@@ -321,13 +321,13 @@ if [[ -z "${LLVM_DIR:-}" || ! -d "$LLVM_DIR" ]]; then
321321
echo "Downloading LLVM binary for $OSDisplayName"
322322
if ! generic_download_file "$urlLLVM" llvm.tar.xz; then
323323
download_llvm_from_apt_repo
324-
export LLVM_DIR="/usr/lib/llvm-$MajorLLVMVer/bin"
324+
export LLVM_DIR="/usr/lib/llvm-$MajorLLVMVer/bin"
325325
else
326326
check_xz
327327
echo "Unzipping llvm package..."
328328
mkdir -p "./$LLVMHome" && tar -xf llvm.tar.xz -C "./$LLVMHome" --strip-components 1
329329
rm llvm.tar.xz
330-
export LLVM_DIR="$SVFHOME/$LLVMHome"
330+
export LLVM_DIR="$SVFHOME/$LLVMHome"
331331
fi
332332
fi
333333
fi
@@ -343,9 +343,10 @@ if [[ -z "${Z3_DIR:-}" || ! -d "$Z3_DIR" ]]; then
343343
if [[ "$sysOS" = "Darwin" ]]; then
344344
echo "Downloading Z3 binary for $OSDisplayName"
345345
brew update
346-
brew install z3
346+
brew install z3 #already installed as a part of llvm dependency on macOS
347347
if [ $? -eq 0 ]; then
348348
echo "z3 binary installation completed."
349+
export Z3_DIR="$(brew --prefix z3)"
349350
else
350351
echo "z3 binary installation failed."
351352
exit 1
@@ -357,15 +358,14 @@ if [[ -z "${Z3_DIR:-}" || ! -d "$Z3_DIR" ]]; then
357358
echo "Downloading Z3 binary for $OSDisplayName"
358359
if ! generic_download_file "$urlZ3" z3.zip; then
359360
exit 1
360-
fi
361+
fi
361362
check_unzip
362363
echo "Unzipping z3 package..."
363364
unzip -q "z3.zip" && mv ./z3-* ./$Z3Home
364365
rm z3.zip
366+
export Z3_DIR="$SVFHOME/$Z3Home"
365367
fi
366368
fi
367-
368-
export Z3_DIR="$SVFHOME/$Z3Home"
369369
fi
370370

371371
# Add LLVM & Z3 to $PATH and $LD_LIBRARY_PATH (prepend so that selected instances will be used first)

setup.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
#!/usr/bin/env bash
22

33
echo "Setting up environment for SVF"
4-
4+
MajorLLVMVer=20
5+
LLVMVer=${MajorLLVMVer}.1.0
56

67
#########
78
# export SVF_DIR, LLVM_DIR and Z3_DIR
89
# Please change LLVM_DIR and Z3_DIR if they are different
910
########
1011

1112
# in a local installation $SVF_DIR is the directory containing setup.sh
12-
SVF_DIR="$(cd -- "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1; pwd -P)"
13+
SVF_DIR="$(cd -- "$(dirname "$0")" >/dev/null 2>&1; pwd -P)"
1314
export SVF_DIR
1415
echo "SVF_DIR=$SVF_DIR"
1516

@@ -18,7 +19,7 @@ function set_llvm {
1819
[[ -n "$LLVM_DIR" ]] && return 0
1920

2021
# use local download directory
21-
LLVM_DIR="$SVF_DIR/llvm-20.0.0.obj"
22+
LLVM_DIR="$SVF_DIR/$LLVMVer.obj"
2223
[[ -d "$LLVM_DIR" ]] && return 0
2324

2425
# ... otherwise don't set LLVM_DIR

svf-llvm/CMakeLists.txt

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -42,22 +42,30 @@ if(LLVM_LINK_LLVM_DYLIB)
4242
endif()
4343
else()
4444
message(STATUS "Linking to separate LLVM static libraries")
45-
llvm_map_components_to_libnames(
46-
llvm_libs
47-
analysis
48-
bitwriter
49-
core
50-
instcombine
51-
instrumentation
52-
ipo
53-
irreader
54-
linker
55-
scalaropts
56-
support
57-
target
58-
transformutils
59-
demangle
45+
# Define base LLVM components
46+
set(llvm_components
47+
analysis
48+
bitwriter
49+
core
50+
instcombine
51+
instrumentation
52+
ipo
53+
irreader
54+
linker
55+
scalaropts
56+
support
57+
target
58+
transformutils
59+
demangle
6060
)
61+
62+
# Conditionally add 'passes' for macOS
63+
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
64+
list(APPEND llvm_components passes)
65+
endif()
66+
67+
# Map components to library names
68+
llvm_map_components_to_libnames(llvm_libs ${llvm_components})
6169
endif()
6270

6371
# Make the "add_llvm_library()" command available and configure LLVM/CMake

0 commit comments

Comments
 (0)