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 quick and dirty support for specifying desired linking mode #6

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
19 changes: 10 additions & 9 deletions setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ if test "$(dirname $0)" != '.'; then
exit 1
fi

if test "$#" -ne 1; then
echo "Usage: $0 <llvm-config>"
if test "$#" -ne 2; then
echo "Usage: $0 <llvm-config> <default-mode>"
exit 1
fi

llvm_config=$1
default_mode=
default_mode=$2
support_static_mode=false
support_shared_mode=false

Expand All @@ -29,23 +29,24 @@ if test "$llvm_version" != "$expected_version"; then
exit 1
fi

if llvm_config --link-static --libs; then
default_mode=static
support_static_mode=true
fi

if llvm_config --link-shared --libs; then
default_mode=shared
default_mode=${default_mode:=shared}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
default_mode=${default_mode:=shared}

support_shared_mode=true
fi

if llvm_config --link-static --libs; then
default_mode=${default_mode:=static}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
default_mode=${default_mode:=static}

support_static_mode=true
fi

if test -z "$default_mode"; then
echo "Something is wrong with the llvm-config command provided."
exit 1
fi
Comment on lines 43 to 46
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
if test -z "$default_mode"; then
echo "Something is wrong with the llvm-config command provided."
exit 1
fi
if test "(" "${default_mode}" = static -a "${support_static_mode}" = false ")" -o \
"(" "${default_mode}" = shared -a "${support_shared_mode}" = false ")" ; then
echo "Mode '${default_mode}' unsupported."
exit 1
fi


base_cflags=$(llvm_config --cflags)
ldflags="$(llvm_config --ldflags) -lstdc++"
ldflags="$(pkg-config --libs-only-L libzstd) $(llvm_config --ldflags) -lstdc++"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This seems unrelated, but I needed it for linking to libllvm in static mode to succeed.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this a LLVM 16 thing? Wouldn't llvm-config --system-libs work here instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

llvm-config --link-static --system-libs does include zstd, giving -lm -lz -lzstd -lcurses -lxml2, so that looks like the way to go when I get back to this.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
ldflags="$(pkg-config --libs-only-L libzstd) $(llvm_config --ldflags) -lstdc++"
ldflags="$(llvm_config --link-static --system-libs --ldflags) -lstdc++"

llvm_targets=$(llvm_config --targets-built)

rm -rf src
Expand Down