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

Documentation for porting Unix-style build process (configure/make) #6509

Open
bvibber opened this issue May 7, 2018 · 7 comments
Open

Documentation for porting Unix-style build process (configure/make) #6509

bvibber opened this issue May 7, 2018 · 7 comments

Comments

@bvibber
Copy link
Collaborator

bvibber commented May 7, 2018

Documentation on doing builds of existing libraries with Unix-style configure/make build processes is a bit scarce, and there are some tricks. Would be nice to add a documentation page summarizing porting concerns.

A few things off the top of my head:

  • passing CFLAGS, PKG_CONFIG_PATH, and other env variables usually should be done as parameters to configure: emconfigure configure --blah CFLAGS="-s WASM=1" etc
  • recommended build steps for multiple libraries / dependencies
    • using out-of-tree build directories for your sanity
    • use --prefix to install multiple libraries into one pseudo system root
    • set include, library paths and PKG_CONFIG_PATH var to point into that root, allowing libraries to find each other
  • use emconfigure along with EMCONFIGURE_JS=2 to make sure configure script code is built for the JS target and not for native!
    • (I'm not sure why the default is to build anything as native, it produces incorrect results for all kinds of detections.)
    • running test compilations through emconfigure instead of emmake? For libffi's test suite, this gets them built as node scripts. Not sure this is really ideal though.
  • issues with dynamic linking vs static linking?
    • I've sometimes had trouble with -lfoo when the default static library generation created libfoo.a.
    • Shared libraries can produce .so or .dylib files based on the build system, which are actually LLVM bitcode (same as .bc)
    • Not sure how to force the autoconf stack to produce a .bc extension for a static library...?
  • recent versions of autoconf support asmjs-unknown-unknown and wasm32-unknown-unknown host triples, so you can pass --host=asmjs or --host=wasm32 on the configure line to flip things into a mode where they know they're cross-compiling! This can help programs know what they're targeting, for instance my in-progress port of libffi needs this or it'll try to build x86_64 assembly stuff.
  • best way to obtain proper dependencies? installing autoconf/automake/pkg-config/libtool/etc on Linux, on Mac, and on Windows?
  • how to get anything working on Windows??
    • note you can't just exec() a configure script, you need to run it through a shell, and other mysteries
@stale
Copy link

stale bot commented Sep 19, 2019

This issue has been automatically marked as stale because there has been no activity in the past year. It will be closed automatically if no further activity occurs in the next 7 days. Feel free to re-open at any time if this issue is still relevant.

@stale stale bot added the wontfix label Sep 19, 2019
@oxr463
Copy link
Contributor

oxr463 commented Sep 19, 2019

Any progress on this?

@stale stale bot removed the wontfix label Sep 19, 2019
@sbc100
Copy link
Collaborator

sbc100 commented Sep 19, 2019

Nope. But lets keep this open

@bplevin36
Copy link

recent versions of autoconf support asmjs-unknown-unknown and wasm32-unknown-unknown host triples, so you can pass --host=asmjs or --host=wasm32 on the configure line to flip things into a mode where they know they're cross-compiling! This can help programs know what they're targeting, for instance my in-progress port of libffi needs this or it'll try to build x86_64 assembly stuff.

I would argue this involves source changes, not just additional docs. In my experience, emcc tries very hard to appear as if it's not a cross-compiler. The large number of hacks and spoofs employed by both emscripten and autotools is what makes using them together so difficult.

@Cloudef
Copy link
Contributor

Cloudef commented Feb 18, 2020

You can see some tricks I'm doing to make projects compile without having to hack them:
https://git.cloudef.pw/pacbox.git/tree/pacbox-toolchain-emscripten.sh

I have been working on this toy thing that lets you create "virtual build environments" based on bubblewrap. The aim is to be able to quickly create environments for compiling packages to weird platforms (such as emscripten or android for example), with little to no changes to the usual build workflow. In fact this leverages the work already done by arch linux packagers and lets you compile a emscripten package by running makepkg as you normally would.

The drawbacks are that it assumes arch linux base, or at least system with pacman installed. The pacman / makepkg requirement probably wont change since it's the main attraction here.

example workflow:

pacbox emscripten toolchain-emscripten
cower -dd zlib-git
cd zlib-git
pacbox emscripten makepkg -ci --skippgpcheck

This builds zlib from git and installs it to the container's filesystem. After that you can compile any program that depends on zlib as usual and so on. You could even distribute the compiled binary packages to others, so they can install them without compiling.

@stale
Copy link

stale bot commented Feb 21, 2021

This issue has been automatically marked as stale because there has been no activity in the past year. It will be closed automatically if no further activity occurs in the next 30 days. Feel free to re-open at any time if this issue is still relevant.

@stale stale bot added the wontfix label Feb 21, 2021
@kripken kripken removed the wontfix label Feb 22, 2021
@stale
Copy link

stale bot commented Apr 16, 2022

This issue has been automatically marked as stale because there has been no activity in the past year. It will be closed automatically if no further activity occurs in the next 30 days. Feel free to re-open at any time if this issue is still relevant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants