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

fix ar situation: don't put the ldd inside libgerbil.a #791

Merged
merged 1 commit into from
Sep 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions doc/guide/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,8 @@ You can configure the use of a specific compiler by
configuring with the `CC=compiler` variable and setting the
`GERBIL_GCC` environment variable to point to your preferred compiler.

On another note about the LLVM toolchain: some versions of LLVM's `ar`
are not capable of recording dynamic library dependencies inside archives.
In this case you should set the `GERBIL_AR` environment variable to point
to a more capable version of ar, like GNU ar. This only applies if
you have configured the system without `--enable-shared`.
If you are having problems with your system's ar, you can also set the
`GERBIL_AR` environment variable to point to a specific `ar` that works.

Finally, Gerbil consults the `GERBIL_BUILD_CORES` environment variable
to determine whether to build its code in parallel, e.g.
Expand Down
19 changes: 9 additions & 10 deletions src/build/build-libgerbil.ss
Original file line number Diff line number Diff line change
Expand Up @@ -387,22 +387,21 @@
(when (file-exists? libgerbil)
(delete-file libgerbil))
(displayln "... build " libgerbil)
(if (eq? mode 'shared)
(let (shared-ld-opts (filter (? (not string-empty?)) (string-split ld-options #\space)))
(let (libgerbil-ldd (filter (? (not string-empty?)) (string-split ld-options #\space)))
(if (eq? mode 'shared)
(invoke-gcc ["-shared" "-o" libgerbil
shared-ld-opts ...
gx-gambc-o-paths ...
static-module-o-paths ...
builtin-modules-o-path
link-o-path])
(call-with-output-file (string-append libgerbil ".ldd")
(cut write shared-ld-opts <>)))
(invoke-ar ["cql" ld-options
libgerbil
gx-gambc-o-paths ...
static-module-o-paths ...
builtin-modules-o-path
link-o-path]))
(invoke-ar ["cq" libgerbil
gx-gambc-o-paths ...
static-module-o-paths ...
builtin-modules-o-path
link-o-path]))
(call-with-output-file (string-append libgerbil ".ldd")
(cut write libgerbil-ldd <>)))
;; cleanup
(for (f [gx-gambc-c-paths ...
static-module-c-paths ...
Expand Down
19 changes: 4 additions & 15 deletions src/gerbil/compiler/driver.ss
Original file line number Diff line number Diff line change
Expand Up @@ -185,19 +185,8 @@ namespace: gxc
(lp rest))
(else [])))))

(def (get-libgerbil.a-ld-opts libgerbil.a)
(let* ((proc (open-input-process [path: (gerbil-ar) arguments: ["p" libgerbil.a "__.LIBDEP"]
stderr-redirection: #f]))
(output (read-line proc #f)))
(unless (zero? (process-status proc))
(raise-compile-error "Compilation error; process exit with nonzero status"
"ar"))
(let* ((line (substring output 0 (1- (string-length output)))) ; drop the NUL terminator
(parts (string-split line #\space))) ; TODO deal with space madness
(filter not-string-empty? parts))))

(def (get-libgerbil.so-ld-opts libgerbil.so)
(call-with-input-file (string-append libgerbil.so ".ldd") read))
(def (get-libgerbil-ld-opts libgerbil)
(call-with-input-file (string-append libgerbil ".ldd") read))

(def (replace-extension path ext)
(string-append (path-strip-extension path) ext))
Expand Down Expand Up @@ -250,9 +239,9 @@ namespace: gxc
(libgerbil-ld-opts
(cond
((file-exists? libgerbil.so)
(get-libgerbil.so-ld-opts libgerbil.so))
(get-libgerbil-ld-opts libgerbil.so))
((file-exists? libgerbil.a)
(get-libgerbil.a-ld-opts libgerbil.a))
(get-libgerbil-ld-opts libgerbil.a))
(else
(raise-compile-error "libgerbil does not exist" libgerbil.a libgerbil.so))))
(gerbil-rpath
Expand Down