comp.lang.ada
 help / color / mirror / Atom feed
* GNAT linking and macOS
@ 2023-09-27 19:30 moi
  2023-09-28 13:32 ` Simon Wright
  0 siblings, 1 reply; 11+ messages in thread
From: moi @ 2023-09-27 19:30 UTC (permalink / raw)


I installed 14.0, Sonoma, on my M1 Mac last night.

The good news:

Using GNAT 12.2.0, it all just works, *so long as* I REMOVE
'-largs -Wl,-ld_classic' from the linker options!

-- 
Bill F.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: GNAT linking and macOS
  2023-09-27 19:30 GNAT linking and macOS moi
@ 2023-09-28 13:32 ` Simon Wright
  2023-09-28 21:00   ` Simon Wright
  0 siblings, 1 reply; 11+ messages in thread
From: Simon Wright @ 2023-09-28 13:32 UTC (permalink / raw)


moi <findlaybill@blueyonder.co.uk> writes:

> I installed 14.0, Sonoma, on my M1 Mac last night.
>
> The good news:
>
> Using GNAT 12.2.0, it all just works, *so long as* I REMOVE
> '-largs -Wl,-ld_classic' from the linker options!

Likewise, but that didn't work for me.

It turns out there's an environment variable DEFAULT_LINKER, which with
the 15.0 CLT would be set to

  export DEFAULT_LINKER=/Library/Developer/CommandLineTools/usr/bin/ld-classic

(the Xcode equivalent is much longer & more inscrutable)

I haven't tried this.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: GNAT linking and macOS
  2023-09-28 13:32 ` Simon Wright
@ 2023-09-28 21:00   ` Simon Wright
  2023-09-29 20:19     ` hn...@yahoo.de
                       ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Simon Wright @ 2023-09-28 21:00 UTC (permalink / raw)


Simon Wright <simon@pushface.org> writes:

> moi <findlaybill@blueyonder.co.uk> writes:
>
>> I installed 14.0, Sonoma, on my M1 Mac last night.
>>
>> The good news:
>>
>> Using GNAT 12.2.0, it all just works, *so long as* I REMOVE
>> '-largs -Wl,-ld_classic' from the linker options!
>
> Likewise, but that didn't work for me.

You can't reinstall the 14.3 CLT under Sonoma (it's "too old"). I
reinstalled from a Time Machine backup, but if you don't have that set
up I'd recommend taking a copy of /Library/Developer/CommandLineTools
before updating to 15.0.

> It turns out there's an environment variable DEFAULT_LINKER, which with
[...]
> I haven't tried this.

This affects building the compiler, not using it.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: GNAT linking and macOS
  2023-09-28 21:00   ` Simon Wright
@ 2023-09-29 20:19     ` hn...@yahoo.de
  2023-09-29 20:26     ` hn...@yahoo.de
  2023-09-30  2:30     ` Kenneth Wolcott
  2 siblings, 0 replies; 11+ messages in thread
From: hn...@yahoo.de @ 2023-09-29 20:19 UTC (permalink / raw)


On Thursday, September 28, 2023 at 11:00:33 PM UTC+2, Simon Wright wrote:
> Simon Wright <si...@pushface.org> writes: 
> 
> > moi <findl...@blueyonder.co.uk> writes: 
> > 
> >> I installed 14.0, Sonoma, on my M1 Mac last night. 
> >> 
> >> The good news: 
> >> 
> >> Using GNAT 12.2.0, it all just works, *so long as* I REMOVE 
> >> '-largs -Wl,-ld_classic' from the linker options! 
> > 
> > Likewise, but that didn't work for me.
> You can't reinstall the 14.3 CLT under Sonoma (it's "too old"). I 
> reinstalled from a Time Machine backup, but if you don't have that set 
> up I'd recommend taking a copy of /Library/Developer/CommandLineTools 
> before updating to 15.0.
> > It turns out there's an environment variable DEFAULT_LINKER, which with
> [...]
> > I haven't tried this.
> This affects building the compiler, not using it.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: GNAT linking and macOS
  2023-09-28 21:00   ` Simon Wright
  2023-09-29 20:19     ` hn...@yahoo.de
@ 2023-09-29 20:26     ` hn...@yahoo.de
  2023-09-30  0:51       ` moi
  2023-09-30 14:20       ` Simon Wright
  2023-09-30  2:30     ` Kenneth Wolcott
  2 siblings, 2 replies; 11+ messages in thread
From: hn...@yahoo.de @ 2023-09-29 20:26 UTC (permalink / raw)


On Thursday, September 28, 2023 at 11:00:33 PM UTC+2, Simon Wright wrote:
> Simon Wright <si...@pushface.org> writes: 
> 
> > moi <findl...@blueyonder.co.uk> writes: 
> > 
> >> I installed 14.0, Sonoma, on my M1 Mac last night. 
> >> 
> >> The good news: 
> >> 
> >> Using GNAT 12.2.0, it all just works, *so long as* I REMOVE 
> >> '-largs -Wl,-ld_classic' from the linker options! 
> > 
> > Likewise, but that didn't work for me.
> You can't reinstall the 14.3 CLT under Sonoma (it's "too old"). I 
> reinstalled from a Time Machine backup, but if you don't have that set 
> up I'd recommend taking a copy of /Library/Developer/CommandLineTools 
> before updating to 15.0.
> > It turns out there's an environment variable DEFAULT_LINKER, which with
> [...]
> > I haven't tried this.
> This affects building the compiler, not using it.

What exactly is meant by "Using GNAT 12.2.0"? I put gcc-13.2.0 in ~/.zshrc. 
Then I got Could not locate executable on path: gprbuild.
What do i miss?

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: GNAT linking and macOS
  2023-09-29 20:26     ` hn...@yahoo.de
@ 2023-09-30  0:51       ` moi
  2023-09-30 14:20       ` Simon Wright
  1 sibling, 0 replies; 11+ messages in thread
From: moi @ 2023-09-30  0:51 UTC (permalink / raw)


On 29/09/2023 21:26, hn...@yahoo.de wrote:
> On Thursday, September 28, 2023 at 11:00:33 PM UTC+2, Simon Wright wrote:
>> Simon Wright <si...@pushface.org> writes:
>>
>>> moi <findl...@blueyonder.co.uk> writes:
>>>
>>>> I installed 14.0, Sonoma, on my M1 Mac last night.
>>>>
>>>> The good news:
>>>>
>>>> Using GNAT 12.2.0, it all just works, *so long as* I REMOVE
>>>> '-largs -Wl,-ld_classic' from the linker options!
>>>
>>> Likewise, but that didn't work for me.
>> You can't reinstall the 14.3 CLT under Sonoma (it's "too old"). I
>> reinstalled from a Time Machine backup, but if you don't have that set
>> up I'd recommend taking a copy of /Library/Developer/CommandLineTools
>> before updating to 15.0.
>>> It turns out there's an environment variable DEFAULT_LINKER, which with
>> [...]
>>> I haven't tried this.
>> This affects building the compiler, not using it.
> 
> What exactly is meant by "Using GNAT 12.2.0"? I put gcc-13.2.0 in ~/.zshrc.
> Then I got Could not locate executable on path: gprbuild.
> What do i miss?

It means using the version that announces itself
at the head of the source listing as:

"GNAT 12.2.0
Copyright 1992-2022, Free Software Foundation, Inc."

What exactly is meant by "I put gcc-13.2.0 in ~/.zshrc"?

-- 
Bill F.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: GNAT linking and macOS
  2023-09-28 21:00   ` Simon Wright
  2023-09-29 20:19     ` hn...@yahoo.de
  2023-09-29 20:26     ` hn...@yahoo.de
@ 2023-09-30  2:30     ` Kenneth Wolcott
  2023-09-30 13:55       ` Simon Wright
  2 siblings, 1 reply; 11+ messages in thread
From: Kenneth Wolcott @ 2023-09-30  2:30 UTC (permalink / raw)


Hi Simon;

>I'd recommend taking a copy of /Library/Developer/CommandLineTools 
> before updating to 15.0.

Well, I should have done this, but I didn't...

> > It turns out there's an environment variable DEFAULT_LINKER, which with

I tried this (xport DEFAULT_LINKER=/Library/Developer/CommandLineTools/usr/bin/ld-classic) and it did not help:

Using:

/opt/gcc-13.1.0-aarch64/bin/gnatmake --version
GNATMAKE 13.1.0

-- This is from Rosetta Code:

with Ada.Text_IO;  use Ada.Text_IO;

procedure Test_Short_Circuit is
   function A (Value : Boolean) return Boolean is
   begin
      Put (" A=" & Boolean'Image (Value));
      return Value;
   end A;
   function B (Value : Boolean) return Boolean is
   begin
      Put (" B=" & Boolean'Image (Value));
      return Value;
   end B;
begin
   for I in Boolean'Range loop
      for J in Boolean'Range loop
         Put (" (A and then B)=" & Boolean'Image (A (I) and then B (J)));
         New_Line;
      end loop;
   end loop;
   for I in Boolean'Range loop
      for J in Boolean'Range loop
         Put (" (A or else B)=" & Boolean'Image (A (I) or else B (J)));
         New_Line;
      end loop;
   end loop;
end Test_Short_Circuit;

gnatmake test_short_circuit.adb
gcc -c test_short_circuit.adb
gnatbind -x test_short_circuit.ali
gnatlink test_short_circuit.ali
-macosx_version_min has been renamed to -macos_version_min
ld: warning: ignoring duplicate libraries: '-lgcc'
0  0x10306b648  __assert_rtn + 72
1  0x102f9ffac  ld::AtomPlacement::findAtom(unsigned char, unsigned long long, ld::AtomPlacement::AtomLoc const*&, long long&) const + 1204
2  0x102fb5924  ld::InputFiles::SliceParser::parseObjectFile(mach_o::Header const*) const + 15164
3  0x102fc304c  ld::InputFiles::parseAllFiles(void (ld::AtomFile const*) block_pointer)::$_7::operator()(unsigned long, ld::FileInfo const&) const + 960
4  0x18e36d950  _dispatch_client_callout2 + 20
5  0x18e3821a4  _dispatch_apply_invoke_and_wait + 176
6  0x18e381464  _dispatch_apply_with_attr_f + 1176
7  0x18e381650  dispatch_apply + 96
8  0x10303d3b8  ld::AtomFileConsolidator::parseFiles(bool) + 292
9  0x102fde170  main + 9048
ld: Assertion failed: (resultIndex < sectData.atoms.size()), function findAtom, file Relocations.cpp, line 1336.
collect2: error: ld returned 1 exit status
gnatlink: error when calling /opt/gcc-13.1.0-aarch64/bin/gcc
gnatmake: *** link failed.

Are there any other workarounds to solve the inability to link?  This does not only adversely affect Ada, but everything that uses a linker, BTW.

Thanks,
Ken Wolcott

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: GNAT linking and macOS
  2023-09-30  2:30     ` Kenneth Wolcott
@ 2023-09-30 13:55       ` Simon Wright
  2023-09-30 23:57         ` Kenneth Wolcott
  0 siblings, 1 reply; 11+ messages in thread
From: Simon Wright @ 2023-09-30 13:55 UTC (permalink / raw)


Kenneth Wolcott <kennethwolcott@gmail.com> writes:

>> > It turns out there's an environment variable DEFAULT_LINKER, which with
>
> I tried this (xport
> DEFAULT_LINKER=/Library/Developer/CommandLineTools/usr/bin/ld-classic)
> and it did not help:

As I said above, this only affects building GCC, not using it. Sorry.

> Are there any other workarounds to solve the inability to link?  This
> does not only adversely affect Ada, but everything that uses a linker,
> BTW.

I have some evidence that the issue only arises with static
libraries. Not much help.

We're hoping that the 15.1 release of Command Line Tools fixes this. In
the meantime,

(1) using gnatmake, or gprbuild without changing the GPR:

  $ gnatmake foo.adb -largs -Wl,-ld_classic
or
  $ gprbuild -P foo -largs -Wl,-ld_classic

(2) modifying the GPR by adding a new package Linker:

  package Linker is
     for Default_Switches ("ada") use ("-Wl,-ld_classic");
  end Linker;

(3) if you already have a package Linker, modify as above.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: GNAT linking and macOS
  2023-09-29 20:26     ` hn...@yahoo.de
  2023-09-30  0:51       ` moi
@ 2023-09-30 14:20       ` Simon Wright
  1 sibling, 0 replies; 11+ messages in thread
From: Simon Wright @ 2023-09-30 14:20 UTC (permalink / raw)


"hn...@yahoo.de" <hnptz@yahoo.de> writes:

> What exactly is meant by "Using GNAT 12.2.0"? I put gcc-13.2.0 in ~/.zshrc. 
> Then I got Could not locate executable on path: gprbuild.
> What do i miss?

First, I asked above where you got GCC 13.2.0 from; you certainly didn't
get it from one of my builds.

If you got it via Homebrew, then be aware that homebrew's gcc *does*
*not* *support* *Ada* (or gprbuild).

There are two ways I know of for getting hold of GNAT and gprbuild:

(1) go to https://alire.ada.dev/docs/#introduction and follow the steps
at 'alr for macOS', then 'First steps' ... This provides GCC 12.2.0 for
x86_64 (intel), which runs on an M1/M2 mac under Rosetta.

(2) go to my release page at
https://github.com/simonjwright/distributing-gcc/releases and download

for Intel:
https://github.com/simonjwright/distributing-gcc/releases/tag/gcc-13.1.0-x86_64

for M1/M2:
https://github.com/simonjwright/distributing-gcc/releases/tag/gcc-13.1.0-aarch64-2

(in both cases, the actual download is found under Assets at the bottom
of the page; but please read the release notes for what's included and
how to install).

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: GNAT linking and macOS
  2023-09-30 13:55       ` Simon Wright
@ 2023-09-30 23:57         ` Kenneth Wolcott
  2023-10-01  7:57           ` Simon Wright
  0 siblings, 1 reply; 11+ messages in thread
From: Kenneth Wolcott @ 2023-09-30 23:57 UTC (permalink / raw)


Hi Simon;

> We're hoping that the 15.1 release of Command Line Tools fixes this.

+1

> In the meantime, 
> 
> (1) using gnatmake, or gprbuild without changing the GPR: 
> 
> $ gnatmake foo.adb -largs -Wl,-ld_classic 
> or 
> $ gprbuild -P foo -largs -Wl,-ld_classic 
> 
> (2) modifying the GPR by adding a new package Linker: 
> 
> package Linker is 
> for Default_Switches ("ada") use ("-Wl,-ld_classic"); 
> end Linker; 
> 
> (3) if you already have a package Linker, modify as above.

I chose option #1a...

Using the Turtle Graphics Rosetta Code example for Ada, I was able to get a successful compile+link:

gnatmake main.adb -largs -Wl,-ld_classic
gcc -c main.adb
gnatbind -x main.ali
gnatlink main.ali -Wl,-ld_classic
-macosx_version_min has been renamed to -macos_version_min

Appreciate the suggestions...

Thanks,
Ken

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: GNAT linking and macOS
  2023-09-30 23:57         ` Kenneth Wolcott
@ 2023-10-01  7:57           ` Simon Wright
  0 siblings, 0 replies; 11+ messages in thread
From: Simon Wright @ 2023-10-01  7:57 UTC (permalink / raw)


Kenneth Wolcott <kennethwolcott@gmail.com> writes:

> -macosx_version_min has been renamed to -macos_version_min

This will be fixed in GCC 14.

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2023-10-01  7:57 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-27 19:30 GNAT linking and macOS moi
2023-09-28 13:32 ` Simon Wright
2023-09-28 21:00   ` Simon Wright
2023-09-29 20:19     ` hn...@yahoo.de
2023-09-29 20:26     ` hn...@yahoo.de
2023-09-30  0:51       ` moi
2023-09-30 14:20       ` Simon Wright
2023-09-30  2:30     ` Kenneth Wolcott
2023-09-30 13:55       ` Simon Wright
2023-09-30 23:57         ` Kenneth Wolcott
2023-10-01  7:57           ` Simon Wright

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox