emscripten-core/emscripten

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

Open

#6,509 opened on 2018年5月7日

GitHub で見る
 (7 comments) (8 reactions) (0 assignees)C++ (3,519 forks)batch import
good first bughelp wantedwontfix

Repository metrics

Stars
 (27,361 stars)
PR merge metrics
 (平均マージ 19d 10h) (30d で 147 merged PRs)

説明

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

コントリビューターガイド