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

Options for loading native libraries #294

Merged
merged 5 commits into from
Jul 17, 2017
Merged

Options for loading native libraries #294

merged 5 commits into from
Jul 17, 2017

Conversation

chrisseaton
Copy link
Collaborator

No description provided.

@eregon eregon self-requested a review July 17, 2017 15:51
end

$LIBS += " -l libssl.#{RbConfig::CONFIG['NATIVE_DLEXT']}"
Copy link
Member

Choose a reason for hiding this comment

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

It's unfortunate we have two mechanisms: OPENSSL_PREFIX for the headers and remap for the libs.

Copy link
Member

Choose a reason for hiding this comment

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

It's also easy to make the mistake to pick up the system header but use another library with -Xcexts.remap

Copy link
Member

Choose a reason for hiding this comment

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

Would it be possible to use the remap system to find the headers, at least for OpenSSL?

Copy link
Member

@eregon eregon Jul 17, 2017

Choose a reason for hiding this comment

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

FWIW MRI uses --with-openssl-dir=PREFIX. rbenv/ruby-build#377 (comment)

Copy link
Collaborator Author

@chrisseaton chrisseaton Jul 17, 2017

Choose a reason for hiding this comment

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

That's an autoconf option - we don't use autoconf in our system.

I'm not sure about combining finding the includes with finding the library. What about making the first thing more precise - make it OPENSSL_INCLUDE_DIR?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Plus that autoconf option hard codes the library path into the executable - that's what we don't want to do.

Copy link
Member

Choose a reason for hiding this comment

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

I think it's good to combine both and only give a prefix-like option, as then it's impossible to pick the headers from one prefix and the lib from another.

Copy link
Member

Choose a reason for hiding this comment

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

e.g.: on Darwin, when installing a gem that directly links against libssl (Puma does for instance), it will by default pick the Homebrew libssl, but use the system openssl.h header, which not going to work.

BTW, installing a gem linking to a native lib also supports this kind of dir option (via dir_config in the extconf.rb):

gem install mysql2 -- --with-mysql-dir=/usr/local/mysql

But indeed, this is build-time config and here we are rather talking about link-time config, which usually doesn't need headers. It might be good to unify them though, for simplicity.

try {
ForeignAccess.sendExecute(executeSulongLoadLibraryNode, sulongLoadLibraryFunction, libraryRubyString);
} catch (UnsupportedTypeException | ArityException | UnsupportedMessageException e) {
throw new JavaException(e);
}
}

private String remapNativeLibrary(String library) {
Copy link
Member

Choose a reason for hiding this comment

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

Needs to be synchronized as well.

Copy link
Member

Choose a reason for hiding this comment

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

Ah, actually not since getNativeLibraryMap() is the only mutator.

Copy link
Member

Choose a reason for hiding this comment

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

It would be good to use Collections.unmodifiableMap to clarify this property.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

Copy link
Member

@eregon eregon left a comment

Choose a reason for hiding this comment

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

This is good enough for now and should solve the problem on Darwin where we cannot use the system libssl (because it's way too old).

@chrisseaton chrisseaton merged commit 191d15d into master Jul 17, 2017
@chrisseaton chrisseaton deleted the openssl-options branch July 17, 2017 20:12
dougxc pushed a commit that referenced this pull request Aug 16, 2018
* commit 'abb98ed83d76306ecf14af4676a625b240f59156':
  Remove repeated property read
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