• GNAT linking and macOS

    From moi@21:1/5 to All on Wed Sep 27 20:30:17 2023
    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.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Simon Wright@21:1/5 to moi on Thu Sep 28 14:32:47 2023
    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.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Simon Wright@21:1/5 to Simon Wright on Thu Sep 28 22:00:29 2023
    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.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From hnptz@yahoo.de@21:1/5 to Simon Wright on Fri Sep 29 13:19:06 2023
    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.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From hnptz@yahoo.de@21:1/5 to Simon Wright on Fri Sep 29 13:26:19 2023
    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?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From moi@21:1/5 to hn...@yahoo.de on Sat Sep 30 01:51:41 2023
    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.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Kenneth Wolcott@21:1/5 to All on Fri Sep 29 19:30:27 2023
    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

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Simon Wright@21:1/5 to Kenneth Wolcott on Sat Sep 30 14:55:09 2023
    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.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Simon Wright@21:1/5 to hn...@yahoo.de on Sat Sep 30 15:20:22 2023
    "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).

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Kenneth Wolcott@21:1/5 to All on Sat Sep 30 16:57:57 2023
    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

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Simon Wright@21:1/5 to Kenneth Wolcott on Sun Oct 1 08:57:34 2023
    Kenneth Wolcott <kennethwolcott@gmail.com> writes:

    -macosx_version_min has been renamed to -macos_version_min

    This will be fixed in GCC 14.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)