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 many things have have been slightly broken in OSX #2618

Merged
merged 5 commits into from Dec 3, 2017

Conversation

jpakkane
Copy link
Member

Basically this steals even more stuff from CMake's implementation:

  • pad rpath entry to maximum size
  • use absolute paths for rpaths

Still needs to be added:

@mojca
Copy link

mojca commented Nov 29, 2017

I tested this with a simple setup:

testbin.cpp

#include "testlib.h"
#include <iostream>
int main()
{
    std::cout << answer() << std::endl;
    return 0;
}

testlib.h:

#pragma once
int answer();

testlib.cpp:

int answer() { return 42; }

meson.build:

project('Test libraries on mac', 'cpp')

testlib = shared_library('testlib', 'testlib.cpp', install: true)
executable('testbin', 'testbin.cpp', link_with : testlib, install: true)

And running

meson --prefix /tmp/inst <sources>
DESTDIR=/tmp/dest ninja install
# as well as once without `DESTDIR`

I end up with

/tmp/inst/lib/testlib.dylib
/tmp/inst/bin/testbin

with

> otool -L /tmp/inst/bin/testbin
 /tmp/inst/bin/testbin:
	@rpath/libtestlib.dylib (compatibility version 0.0.0, current version 0.0.0)
	/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 400.9.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.0.0)

>  /tmp/inst/bin/testbin
dyld: Library not loaded: @rpath/libtestlib.dylib
  Referenced from: /tmp/inst/bin/testbin
  Reason: image not found
Abort trap: 6

Note that the binary works as long as libtestlib.dylib is in the current folder which is why you don't notice the failure right away.

So basically this doesn't seem to work for me. (I would also like to occasionally keep the liberty to keep using absolute paths, but that's a lower priority. Current solution would also not work on 10.4, but well ...)

@jpakkane
Copy link
Member Author

Can you try writing the same in CMake and trying it out? It would be interesting to know if and how they do it. Thanks.

@mojca
Copy link

mojca commented Nov 29, 2017

I need some more time to figure out what's the proper CMakeLists.txt file since a very simple example results in an equally broken library. I've put the (so far incomplete) sources here.

@jpakkane
Copy link
Member Author

jpakkane commented Dec 3, 2017

Thanks. I'll merge this now because it improves things and does not seem to regress anything. We can fix the other issues in other MRs.

@jpakkane jpakkane merged commit 554b484 into master Dec 3, 2017
@jpakkane jpakkane deleted the osxlinkerfixes branch December 3, 2017 00:25
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

2 participants