antlr / antlr4

ANTLR (ANother Tool for Language Recognition) is a powerful parser generator for reading, processing, executing, or translating structured text or binary files.
http://antlr.org
BSD 3-Clause "New" or "Revised" License
17.26k stars 3.29k forks source link

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

Open boitet2002 opened 1 month ago

boitet2002 commented 1 month ago

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

2) 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 commented 1 month ago

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

kaby76 commented 1 month ago

I'm having a hard time determining the exact URLs for these .jars and C++ libraries. Please be specific, e.g., https://repo1.maven.org/maven2/org/antlr/antlr4-runtime/4.13.2/antlr4-runtime-4.13.2.jar or https://github.com/antlr/website-antlr4/blob/gh-pages/download/antlr-4.13.2-complete.jar or https://github.com/antlr/website-antlr4/blob/gh-pages/download/antlr4-cpp-runtime-4.13.2-macos.zip or https://github.com/antlr/website-antlr4/blob/gh-pages/download/antlr4-cpp-runtime-4.13.2-source.zip etc. I can't find the file named "antlr4-complete.jar" on https://repo1.maven.org/maven2/org/antlr/antlr4-runtime/ nor https://github.com/antlr/website-antlr4/tree/gh-pages/download.

boitet2002 commented 1 month ago

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

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