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

Dynamic ANTLR C++ library not loaded because searched for (in Mac arm64) in the antlr.org Terence Parr's programs #4707

Open
boitet2002 opened this issue Sep 30, 2024 · 4 comments

Comments

@boitet2002
Copy link

boitet2002 commented Sep 30, 2024

We are developing on 2 Macs under Sequoia and ANTLR4-4.13.2.
After migrating one Mac to ARM64, we use the "fat" .dylib (and .a).
Compiling our application was OK on both Macs.
But link-edit gave problems on the arm64 Mac.
We found brew did not generate the fat version.

Then we abandoned brew and downloaded the antlr4-complete.jar and the antlr4-runtime
from the antlr.org web site.
At that point, the link-edit problem disappeared.

Note that, in our project, the ANTLR libs are renamed (by the way of symbolic links) to include the ANTLR version number
(libantlr4-4.13.2.dylib is a link to libantlr4.dylib)

A new problem appears now at execution time, only on the arm64 Mac:
the dynamic library does not load properly (see trace below).
More precisely, the loader looks for
/Users/parrt/antlr/code/antlr4/runtime/Cpp/runtime/libantlr4-runtime.4.13.2.dylib
and does not find it (of course).

But why? We certainly don't want our programs to access T. Parr's disks at run time!
As the trace shows, our libs are at a correct place on our disks, and have the correct format.
What should we do? Or is it a bug?

Thanks for help -- we are on that problem since 1 week.
Also, trying to regenerate the entire ANTLR/C++ tool failed (we are not competent enough with the
CMake tool).

Thanks in advance,

Ch.Boitet and J.C. Durand

============= trace ===============

  1. trying to execute

...Serveur: lldb serveur.out
(lldb) target create "serveur.out"
Current executable set to '/Users/boitet/ariane-y/Ariane-Y_prog_2013/Moniteurs/Moniteur-AY/Serveur/serveur.out' (arm64).
(lldb) pr la
Process 34520 launched: '/Users/boitet/ariane-y/Ariane-Y_prog_2013/Moniteurs/Moniteur-AY/Serveur/serveur.out' (arm64)

dyld[34520]: Library not loaded: /Users/parrt/antlr/code/antlr4/runtime/Cpp/runtime/libantlr4-runtime.4.13.2.dylib
Referenced from: <2CF14B04-8497-3164-973F-5F234426ECFC> /Users/Shared/Dev_ex_PC_ou_Linux/Ariane-Y/ariane-y/Ariane-Y_prog_2013/Moniteurs/Moniteur-AY/Serveur/serveur.out

Reason: tried: '/Users/parrt/antlr/code/antlr4/runtime/Cpp/runtime/libantlr4-runtime.4.13.2.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Users/parrt/antlr/code/antlr4/runtime/Cpp/runtime/libantlr4-runtime.4.13.2.dylib' (no such file), '/Users/parrt/antlr/code/antlr4/runtime/Cpp/runtime/libantlr4-runtime.4.13.2.dylib' (no such file)
Process 34520 stopped

  • thread Move _modeStack=new ArrayDeque to declaration, and related changes. #1, stop reason = signal SIGABRT
    frame #0: 0x00000001988e0628 dyld__abort_with_payload + 8 dyld__abort_with_payload:
    -> 0x1988e0628 <+8>: b.lo 0x1988e0648 ; <+40>
    0x1988e062c <+12>: pacibsp
    0x1988e0630 <+16>: stp x29, x30, [sp, #-0x10]!
    0x1988e0634 <+20>: mov x29, sp
    Target 0: (serveur.out) stopped.
    (lldb) q
    Quitting LLDB will kill one or more processes. Do you really want to proceed: [Y/n]
  1. checking the libs

...Serveur: file /usr/local/lib/antlr4-4.13.2/libantlr4-4.13.2.dylib
/usr/local/lib/antlr4-4.13.2/libantlr4-4.13.2.dylib: Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit dynamically linked shared library x86_64] [arm64:Mach-O 64-bit dynamically linked shared library arm64]
/usr/local/lib/antlr4-4.13.2/libantlr4-4.13.2.dylib (for architecture x86_64): Mach-O 64-bit dynamically linked shared library x86_64
/usr/local/lib/antlr4-4.13.2/libantlr4-4.13.2.dylib (for architecture arm64): Mach-O 64-bit dynamically linked shared library arm64
...Serveur:
...Serveur:
...Serveur: pwd
/Users/boitet/ariane-y/Ariane-Y_prog_2013/Moniteurs/Moniteur-AY/Serveur

@boitet2002 boitet2002 changed the title Dynamic ANTLR library not loaded because searched for (in Mac arm64) on the antlr.org Terence Parr's programs Dynamic ANTLR library not loaded because searched for (in Mac arm64) in the antlr.org Terence Parr's programs Sep 30, 2024
@boitet2002
Copy link
Author

I don't know why the last part of the problem description became bold and in a large fount. Sorry about that!

@boitet2002 boitet2002 changed the title Dynamic ANTLR library not loaded because searched for (in Mac arm64) in the antlr.org Terence Parr's programs Dynamic ANTLR C++ library not loaded because searched for (in Mac arm64) in the antlr.org Terence Parr's programs Sep 30, 2024
@boitet2002
Copy link
Author

Hi Kaby76,thanks for the message!

You are "having a hard time determining the exact URLs for these .jars and C++ libraries."
We also! We should never access them -- and we DON'T on our x86_64 Mac. But we DO on our arm64 Mac!
Recap:
We use ANTLR with C++ target, and also with Java target. Everything is fine on our x86_64 Mac.
After migrating to arm64, we got some problems. Then we reinstalled ANTLR (4.13.2) on both
Macs to have the same latest version (up from 4.13.1).

We downloaded (from the page https://www.antlr.org/download.html) 2 files:

(1)
==> This downloaded as antlr-4.13.2-complete.jar,
we put it in /usr/local/antlr-4.13.2-complete.jar

(2)
==> This downloads as Mac OS X universal lib binaries: antlr4-cpp-runtime-4.13.2-macos.zip (.a, .dylib, .h)
==> automatically uncompressed and manually put in /usr/local/antlr4-cpp-runtime-4 (-4, not -4.13.2)
==> In turn, that antlr4-cpp-runtime-4 folder contains:
antlr4-runtime/ which contains all the .h
lib/ which contains the 2 libs generated as "fat"
libantlr4-runtime.dylib (1.8 Mb) executable Unix file
libantlr4-runtime.a (3.6 Mb)

We access the libs using 2 symbolic links put in /usr/local/lib:
/usr/local/lib/antlr4-4.13.2/libantlr4-4.13.2.dylib
/usr/local/lib/antlr4-4.13.2/libantlr4-4.13.2.a

Compiling our programs is OK on the 2 Macs
Executing our programs is OK with x86_64, and not OK with ARM64

==> Hence our question.

@boitet2002
Copy link
Author

I completed my "comment", but how to understand "closed"?
Our problem is not solved...

@boitet2002 boitet2002 reopened this Oct 2, 2024
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

2 participants