Skip to content

Modify nginx compile script for dynamic compilation#175

Open
rishabhBudhouliya wants to merge 4 commits intomainfrom
dynamic-compile-nginx
Open

Modify nginx compile script for dynamic compilation#175
rishabhBudhouliya wants to merge 4 commits intomainfrom
dynamic-compile-nginx

Conversation

@rishabhBudhouliya
Copy link
Copy Markdown
Contributor

Branch: dylink_impl_multi_process in lind-wasm introduces dynamic compilation.

Changes made to script:

  1. LIND_DYLINK env var toggle (default 0)
  2. CFLAGS: adds -fPIC when LIND_DYLINK=1
  3. LDFLAGS (dynamic mode):
    - -nostartfiles + 3 custom CRT objects (set_stack_pointer.o, crt1_shared.o, lind_utils.o)
    - -Wl,-pie --import-table --allow-undefined --unresolved-symbols=import-dynamic
    - Exports: __wasm_call_ctors, __wasm_init_tls (if-defined), __tls_base
    - Validates CRT objects exist at startup with helpful error messages
  4. wasm-opt (dynamic mode):
    - Uses --enable-bulk-memory --enable-threads
    - --epoch-injection --pass-arg=epoch-import --pass-arg=epoch-main-module
    - --asyncify --pass-arg=asyncify-import-globals
    - No --fpcast-emu, no -O2 (matches lmbench pattern)
  5. add-export-tool post-link step (dynamic only):
    - __wasm_apply_tls_relocs (func, optional)
    - __wasm_apply_global_relocs (func, optional)
    - __stack_pointer (global, required)
  6. Cache signature includes dylink=$LIND_DYLINK so switching modes triggers reconfigure

Copy link
Copy Markdown
Contributor

@vidyalakshmir vidyalakshmir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rishabhBudhouliya Regarding lmbench, I had some questions.

  • Shouldn't the compiler flag add -fPIC while compiling?
  • Is libtirpc a library, if so its .so file should be produced and it be not statically compiled with lmbench

Comment thread nginx/compile_nginx.sh
if [[ "$LIND_DYLINK" == "1" ]]; then
echo "[nginx] running wasm-opt (dylink-aware: epoch-import + asyncify-import-globals)..."
"$WASM_OPT" \
--enable-bulk-memory --enable-threads \
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also noticed that there is no --fpcast-emu flag for the dynamic build.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I missed that. I also didn't test the network lmbench tests also so didn't notice a failure.

@rishabhBudhouliya
Copy link
Copy Markdown
Contributor Author

@vidyalakshmir The -fPIC flag is present under the DYLINK=1 section here:

if [[ "$LIND_DYLINK" == "1" ]]; then
echo "[lmbench] Dynamic linking mode enabled (LIND_DYLINK=1)"
CFLAGS+=" -fPIC"
# add-export-tool is used after linking to export relocation and stack symbols

@vidyalakshmir
Copy link
Copy Markdown
Contributor

@vidyalakshmir The -fPIC flag is present under the DYLINK=1 section here:

if [[ "$LIND_DYLINK" == "1" ]]; then
echo "[lmbench] Dynamic linking mode enabled (LIND_DYLINK=1)"
CFLAGS+=" -fPIC"
# add-export-tool is used after linking to export relocation and stack symbols

Thanks!

@rishabhBudhouliya
Copy link
Copy Markdown
Contributor Author

@vidyalakshmir libtirpc perhaps should be dynamically linked but it is being statically compiled as before. I am unsure whether linking multiple dependencies dynamically is supported by lind-boot currently and if so, what are the steps to do so.

@vidyalakshmir
Copy link
Copy Markdown
Contributor

@rishabhBudhouliya
Nginx seems to work. The only thing which we need to look into is it depends on any other library other than libc. I did not have to pass any other library explicitly for the tests and since build script disables libraries like openssl, I assume we do not, but worth checking.

For lmbench, I got the following errors. Are these expected failures similar to the static build?

[FAIL] lat_sig (exit 134)
[FAIL] lat_fifo (exit 124)
[FAIL] lat_unix (exit 124)
[FAIL] memsize (exit 134)
[FAIL] par_mem (exit 124)
[FAIL] tlb (exit 124)
[lmbench-test] 29/35 tests passed, 6 failed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants