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

- Expose and implement append_decorations method to build the library… #23

Merged
merged 3 commits into from Jan 3, 2019

Conversation

Projects
None yet
2 participants
@Firefly35
Copy link

Firefly35 commented Oct 31, 2018

… path without loading the library.

It allows to get the concrete path that will be loaded and allows the user to use the concrete path prior to effectively load the library.

  • #22 (which is similar to #19) issue proposal fix :Add error handling for posix platforms (gnu compiler compilation) when a library with missing symbols is asked for loading : check the library path exists and we do not try to load the current executable.
    In this case : return the current dlerror (useless to try the exactly specified path as the decorated path points to a valid shared library file).
Loïc TOURAINE
- Expose and implement append_decorations method to build the library…
… path without loading the library.

It allows to get the concrete path that will be loaded and allows the user to use the concrete path prior to effectively load the library.
- Add error handling for posix platforms (gnu compiler compilation) when a library with missing symbols is asked for loading : check the library path exists and we do not try to load the current executable.
In this case : return the current dlerror (useless to try the exactly specified path as the decorated path points to a valid shared library file).

Loïc TOURAINE added some commits Nov 12, 2018


if (handle_) {
return;
}
if (boost::filesystem::exists(load_path)) {
// decorated path exists : current error is not a bad file descriptor
ec = boost::dll::detail::last_error_code();

This comment has been minimized.

@apolukhin

apolukhin Nov 30, 2018

Member

That's the wrong way to use last_error_code. The last_error_code function must be called immediately after the system function in wich error code we are interested in. Putting filesystem::exists between the LoadLibrary and last_error_code breaks the error reporting.

So just move the ec = boost::dll::detail::last_error_code(); line before the if statement. That will do the job.

@@ -511,6 +511,26 @@ class shared_library
return base_t::suffix();
}

/*!
* Returns the decorated path to a shared module name, i.e. with needed prefix/suffix added.

This comment has been minimized.

@apolukhin

apolukhin Nov 30, 2018

Member

Need more scary notes:
Returns the decorated path to a shared module name for the current runtime environment, i.e. ...
Calling this function with different current directories may produce different results.

This comment has been minimized.

@Firefly35

Firefly35 Nov 30, 2018

Author

Can you explain what you mean with "different current directories" ?

This comment has been minimized.

@apolukhin

apolukhin Nov 30, 2018

Member

Ther result of shared_library::decorate("foo") may not be the same, if user changes the current directory via https://en.cppreference.com/w/cpp/filesystem/current_path
For example it may return libfoo.so and foo.so, depending on the working directory.

Oh, one more thing: please add a test, that if we create an empty file with name test_broken.so and try to load it, then the the loading fails. You may also write some other tests.

@apolukhin

This comment has been minimized.

Copy link
Member

apolukhin commented Nov 30, 2018

Almost ready for merge :)

@apolukhin apolukhin merged commit c0a5b8d into boostorg:develop Jan 3, 2019

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
@apolukhin

This comment has been minimized.

Copy link
Member

apolukhin commented Jan 3, 2019

Many thanks for the PR!

I've changed a few things in 7981565

We need a better name for the decorate(). It must be scary so that people would not use it without huge need.

@Firefly35

This comment has been minimized.

Copy link
Author

Firefly35 commented Jan 7, 2019

Thanks Antony, feel sorry that I didn't have time to finalize the PR with your comments.
I wish you an happy new year for 2019.

@apolukhin

This comment has been minimized.

Copy link
Member

apolukhin commented Jan 8, 2019

Thanks to you! You made the most part of the job.

Happy new Year :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.