AdaCore / libadalang

Ada semantic analysis library.
https://www.adacore.com
Other
147 stars 42 forks source link

Please support LDFLAGS #958

Closed simonjwright closed 1 year ago

simonjwright commented 1 year ago

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 commented 1 year ago

Hi Simon,

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

simonjwright commented 1 year ago

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 commented 1 year ago

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

thvnx commented 1 year ago

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.

simonjwright commented 1 year ago

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 commented 1 year ago

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