Statically linking C code into ECL

Daniel Kochmański daniel at turtleware.eu
Mon Dec 26 16:06:27 UTC 2016


Faré writes:

> Is there an official or encouraged way?

No.

>> builder (and all interfaces built on top of it) support ld-flags key
>> argument. Additionally if you want to influence how ECL compiles files
>> dynamically you may shadow *user-cc-flags* and *user-ld-flags*.
>>
> This won't work. *user-cc-flags* isn't used by build-program, AFAICT,
> and user-ld-flags is only used at the end of the linking command,
> which is too late for a --whole-archive (and a --no-whole-archive is
> actually needed before the -ldl -lm etc. calls, whereas on Darwin, the
> -force_load is needed in front of each individual .a).

*user-cc-flags* and *user-ld-flags* are used in all operations involving
C/C++ compiler. If it's too late, then what about (mentioned in the
previous mail) :ld-flags ?

(let ((c::*compile-verbose* t)
               (*compile-print* t))
           (c::builder :program "sdbam" :lisp-files '("/home/jack/test.c")
                       :ld-flags '("ld-flag-bam=3")))

(RUN-PROGRAM "gcc" ("-o" "sdbam" "-L/usr/local/lib/"
                    "/tmp/eclinitPjB9n2.o" "test.c"
                    "ld-flag-bam=3"
                    "-Wl,--rpath,/usr/local/lib/" "-lecl"
                    "-lgmp" "-lgc" "-lgc" "-lgc" "-lpthread"
                    "-ldl" "-lm"))

ld-flag-bam=3 is passed before -ldl -lm etc (that, of course, won't
work, because ld-flag=bam=3 doesn't make much sense), so if that's what
you want, just pass :ld-flags to c:build-*.

-- 
Daniel Kochmański ;; aka jackdaniel | Przemyśl, Poland
TurtleWare - Daniel Kochmański      | www.turtleware.eu

"Be the change that you wish to see in the world." - Mahatma Gandhi



More information about the ecl-devel mailing list