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 explanatory message to linker command output on link failure #5486

Merged
merged 1 commit into from
Jan 5, 2018

Conversation

RX14
Copy link
Contributor

@RX14 RX14 commented Dec 30, 2017

When the linker fails to find shared object files, print an explanatory message after the original output to aid users in debugging their problem.

See #5291.

@asterite
Copy link
Member

asterite commented Jan 2, 2018

I like this. I always thought about doing this but was lazy to.

Maybe we could show the relevant messages at the end of the compilation? I think having those new messages intermixed with everything else makes them easier to miss. Alternatively, we could show those messages in yellow, similar to did you mean? messages.

Yet another possibility is even checking what lib declarations are attached to the -lflag flags, and saying "development libraries for LibYAML` or something that (but maybe this doesn't help much).

@RX14
Copy link
Contributor Author

RX14 commented Jan 2, 2018

@asterite yeah I think highlighting in yellow is a good idea. I'll do that.

@RX14
Copy link
Contributor Author

RX14 commented Jan 2, 2018

Added colour highlighting.

@asterite
Copy link
Member

asterite commented Jan 2, 2018

Just tried this in mac: it doesn't work. The error I get is:

ld: library not found for -lfoo

so we probably need a different path for mac.

@RX14
Copy link
Contributor Author

RX14 commented Jan 2, 2018

On that note: a test file

@[Link("nonexistant")]
lib Nope
  fun bar
end

Nope.bar

Running this should produce the error.

@RX14
Copy link
Contributor Author

RX14 commented Jan 2, 2018

@asterite The difference is lld vs gnu ld. gold and bfd use "cannot find -lfoo" the same as GNU ld.

I'll just replace both strings on all platforms.

@RX14
Copy link
Contributor Author

RX14 commented Jan 2, 2018

Fixed when using lld.

@asterite
Copy link
Member

asterite commented Jan 2, 2018

Still doesn't work for me. None of the gsub calls catch the error I get:

ld: library not found for -lfoo

@RX14
Copy link
Contributor Author

RX14 commented Jan 2, 2018

@asterite oh, looks like the strings are different on my lld to yours...

@asterite
Copy link
Member

asterite commented Jan 2, 2018

Mmm... I'm using ld on mac, not sure it's GNU-related, gold, or anything like that.

When the linker fails to find shared object files, print an explanatory message
after the original output to aid users in debugging their problem.
@RX14
Copy link
Contributor Author

RX14 commented Jan 5, 2018

@asterite updated!

Copy link
Member

@asterite asterite left a comment

Choose a reason for hiding this comment

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

Thanks, it works now! 🎉

@RX14 RX14 added this to the Next milestone Jan 5, 2018
@RX14 RX14 merged commit 3d7320d into crystal-lang:master Jan 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants