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

Conversation

jberdine
Copy link
Contributor

This is not worked through diligently enough to merge in its current
state, I'm just sending this PR to share an idea of how to let client
projects specify the desired linking mode to use.

@jberdine jberdine marked this pull request as draft April 16, 2023 19:18
if test -z "$default_mode"; then
echo "Something is wrong with the llvm-config command provided."
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.

@jberdine
Copy link
Contributor Author

CC @alan-j-hu just FYI

Copy link
Collaborator

@kit-ty-kate kit-ty-kate left a comment

Choose a reason for hiding this comment

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

This should work just fine and it looks like it returns something sensible with LLVM-17


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}

if test -z "$default_mode"; then
echo "Something is wrong with the llvm-config command provided."
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
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++"

Comment on lines 43 to 46
if test -z "$default_mode"; then
echo "Something is wrong with the llvm-config command provided."
exit 1
fi
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

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