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

Fix pkg-config: command not found errors #3018

Merged
merged 2 commits into from
Jul 20, 2016
Merged

Fix pkg-config: command not found errors #3018

merged 2 commits into from
Jul 20, 2016

Conversation

timcraft
Copy link
Contributor

On OS X I sometimes get the following output on stderr:

--: pkg-config: command not found
--: pkg-config: command not found

From what I can tell from scanning through the source I think this is because src/openssl/lib_crypto.cr and src/openssl/lib_ssl.cr call out to pkg-config without checking if pkg-config exists (unlike src/compiler/crystal/codegen/link.cr which checks).

A better fix might be to explicitly declare the alternate flags, but I don't know enough about dealing with system libs and your preferences on how to structure that, so I've gone for the simpler fix of redirecting to /dev/null (as src/llvm/lib_llvm.cr does).

Redirect errors to /dev/null when calling out to pkg-config.
@jhass
Copy link
Member

jhass commented Jul 20, 2016

Right, should've done something like that. What do you think of prepending command -v pkg-config >/dev/null && instead to not swallow other possibly relevant error output?

I don't quite follow hat you mean with

A better fix might be to explicitly declare the alternate flags

@timcraft
Copy link
Contributor Author

Agree it would be better not to swallow any other error output.

By declaring alternate flags I mean that this...

@[Link(ldflags: "`pkg-config --libs libssl || printf %s '-lssl -lcrypto'`")]

Could conceivably be specified like this...

@[Link("libssl", some_option_name: "-lssl -lcrypto")]

@jhass
Copy link
Member

jhass commented Jul 20, 2016

Oh, you mean baked in pkg-config handling? Perhaps, I wouldn't be opposed to that personally.

@timcraft
Copy link
Contributor Author

Yep. The code in src/compiler/crystal/codegen/link.cr checks if pkg-config exists before calling it, so if there was another form of Link attribute which could handle the openssl case then that could benefit from re-using the existing link.cr code. Alternatively if it's unlikely that would be used for anything else then having openssl as a special case seems reasonable, providing it behaves similarly (i.e. doesn't output errors if pkg-config isn't found).

@jhass
Copy link
Member

jhass commented Jul 20, 2016

For now let's workaround it with command -v pkg-config >/dev/null && here and then please open a new issue to discuss general pkg-config support for @[Link] :)

@timcraft
Copy link
Contributor Author

Sure, I've just added another commit to use command -v instead of redirecting stderr.

@jhass jhass merged commit efb896c into crystal-lang:master Jul 20, 2016
@jhass
Copy link
Member

jhass commented Jul 20, 2016

Thank you!

@asterite asterite added this to the 0.19.0 milestone Jul 22, 2016
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.

None yet

3 participants