I've just compiled GCC from source, which gave me a libgccjit.so file to dynamically include from my program. However, perhaps I wouldn't want to bundle the file alongside the program if I were to give it to someone else. How do I statically include libgccjit?
- I've tried using
-staticin GCC, but that doesn't see the.sofile ("cannot find-lgccjit: No such file or directory"). - I've tried using
--enable-staticand even--disable-sharedwhen compiling GCC, but somehow that doesn't actually give me thelibgccjit.afile I need. - I've tried packaging the
.ofiles included inlibgccjit.somanually viaar, but that explodes, filling my terminal with an absolutely massive amount of undefined reference errors, probably because the files were made in C++ and not C.
gcccreates a.sofor a [whatever] reason (It does use.awhen needed). Instead of just doing the easy thing of shipping the.so(or not shipping a customgccat all), this is [seems like] an artificial (and problematic--as you found out!) restriction. It's easy enough to ship the.so(or ship everything in a [docker] container)..dllinstead. You'll have to do a full rebuild anyway because windows PE format files and [linux] ELF files aren't compatible. Neither are the ABIs (what function call args are passed in what H/W registers). And, the syscall mechanisms are different. Again, you probably want a container. Or, put everything under your own top level directory (e.g./usr/local/mystuff/{bin,lib,man}) including all your non-standardgccfiles.gccat all? Will it have a customlibcas well to fit the target system? To my mind, the only reason for this is that (e.g.)libgccjit.sois not built/shipped by default for most distros. So, can you ship justlibgccjit.soor do you need a number of other [compatible] files as well (e.g.libgcc.a)? What other libraries/source [that you design/create] are providing the real value? (e.g.) "I wrote a matrix multiply library that is 20% faster". This is not a new problem. I'd look at existing packages that solve similar problems.libgccjitonly as a shared library. Note that you will effectively link in entire GCC, and your resulting program will be covered by GPL. As for packaging all the*.ofiles -- surely you can look at the link line forlibgccjit.soand use the same object files and libraries to link it all statically into your binary. Finally,libgccjit.sodocumentation mentions that it links inlibbackend.awhere most of the compiler "lives"; perhaps you didn't link that?