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

Please support LDFLAGS #958

Closed
simonjwright opened this issue Mar 24, 2023 · 6 comments
Closed

Please support LDFLAGS #958

simonjwright opened this issue Mar 24, 2023 · 6 comments

Comments

@simonjwright
Copy link

simonjwright commented Mar 24, 2023

This is mainly triggered by use on macOS via Alire.

On macOS, we have to use relocatable builds because static SALs don’t work (gprbuild issue 97), and this means that we need to provide libgmp.dylib.

The macOS compilers available via Alire don’t search /usr/local by default, which means that we have to tell gprbuild where to look, and the only obvious mechanism is via LDFLAGS.

Please see also Langkit issue 647.

@thvnx
Copy link
Contributor

thvnx commented Mar 27, 2023

Hi Simon,

Did you try to add /usr/local/lib (I guess you are using Homebrew) to the DYLD_LIBRARY_PATH environment variable?

@simonjwright
Copy link
Author

Laurent,

On Apple silicon, that’d be /opt/homebrew/lib.

But in any case, DYLD_LIBRARY_PATH is for finding a dylib after you’ve got a link: my problem is getting a link in the first place!

@simonjwright
Copy link
Author

And, for security reasons, DYLD* environment variables aren’t passed through to subshells

@thvnx
Copy link
Contributor

thvnx commented Mar 31, 2023

I'm not sure to understand your need then.

I tried to build the example of https://docs.adacore.com/live/wave/libadalang/html/libadalang_ug/ada_api_tutorial.html using Alire on macOS 11.7.4.

I finally succesfully build it with:

# 1/ install libadalang with alire and set env using alire printenv
# 2/ create the main.adb and lal_test.gpr files from the  toturial above (section 4.2.1)
# 3/ set some variable for gcc to find the gmp lib and include files
$ export C_LIBRARY_PATH=/usr/local/include
$ export LIBRARY_PATH=/usr/local/lib
# 4/ build the test project
$ gprbuild lal_test.gpr -XLIBRARY_TYPE=relocatable
$ obj/main main.adb
== main.adb ==
Line 35: Context : constant LAL.Analysis_Context := LAL.Create_Context;
Line 40: Filename : constant String := Ada.Command_Line.Argument (I);
Line 41: Unit     : constant LAL.Analysis_Unit :=\x0a            Context.Get_From_File (Filename);

Is that what you are trying to do?

Also, note that we do not support macOS, so there is no warrantly that it will continue to work in the future.

@pmderodat pmderodat reopened this Oct 2, 2023
@simonjwright
Copy link
Author

The macOS compilers available via Alire don’t search /usr/local by default, which means that we have to tell gprbuild where to look, and the only obvious mechanism is via LDFLAGS.

@thvnx mentioned LIBRARY_PATH, which informs GCC when linking and is now set by Alire on macOS to include Homebrew (or MacPorts) library paths.

So as far as I’m concerned we can close this as 'not needed'.

@pmderodat
Copy link
Member

Ok, thank you for letting us know. :-)

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

No branches or pull requests

3 participants