Skip to content

Conversation

robinyuan1002
Copy link
Contributor

There are mainly three scripts. One bootstrap for libtirpc, one bootstrap for lmbench and a shell script for compiling lmbench tests.

Copy link
Member

@m-hemmings m-hemmings left a comment

Choose a reason for hiding this comment

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

To align with the proposed build contract style from issue 10 here are my suggestions:

  1. Create a makefile that performs the make actions you need (all and clean)
  2. Set up the folder structure similar to this:
lmbench/
├── Makefile
├── compile_lmbench.sh
├── out/
│   ├── lat_syscall.cwasm
│   └── syscall.cwasm
└── sysroot_overlay/
    ├── include/
    │   └── wasm32-wasi/
    │       ├── netconfig.h
    │       └── rpc/
    │           ├── svc.h
    │           └── clnt.h
    └── lib/
        └── wasm32-wasi/
            └── libc.a

  1. Change the scripts to not modify the sysroot or files therein directly, but instead place them into the sysroot_overlay folder and allow the tooling script to manage merging. It will call the make all and then handle merging the files into the appropriate places following the folder structure relative to sysroot that you put in that folder (example above)

./autogen.sh
fi

export AR=/home/lind/lind-wasm/clang+llvm-16.0.4-x86_64-linux-gnu-ubuntu-22.04/bin/llvm-ar
Copy link
Member

Choose a reason for hiding this comment

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

Since the script depends on several specific tools (clang, wasm-opt, wasmtime, and a specific SYSROOT), it might be a good idea to move all the path exports and environment variable setups to the top of the script using fallbacks like this:

export CLANG="${CLANG:-/home/lind/lind-wasm/clang+llvm-16.0.4-x86_64-linux-gnu-ubuntu-22.04/bin/clang}"
export CXX="${CXX:-/home/lind/lind-wasm/clang+llvm-16.0.4-x86_64-linux-gnu-ubuntu-22.04/bin/clang++}"
export AR="${AR:-/home/lind/lind-wasm/clang+llvm-16.0.4-x86_64-linux-gnu-ubuntu-22.04/bin/llvm-ar}"
export LD="${LD:-/home/lind/lind-wasm/clang+llvm-16.0.4-x86_64-linux-gnu-ubuntu-22.04/bin/wasm-ld}"
export RANLIB="${RANLIB:-/home/lind/lind-wasm/clang+llvm-16.0.4-x86_64-linux-gnu-ubuntu-22.04/bin/llvm-ranlib}"

export WASM_OPT="${WASM_OPT:-/home/lind/lind-wasm/tools/binaryen/bin/wasm-opt}"
export WASMTIME="${WASMTIME:-/home/lind/lind-wasm/src/wasmtime/target/debug/wasmtime}"

export SYSROOT="${SYSROOT:-/home/lind/lind-wasm/src/glibc/sysroot}"

export CFLAGS="${CFLAGS:---sysroot=$SYSROOT -g -O2}"
export CXXFLAGS="${CXXFLAGS:---sysroot=$SYSROOT -g -O2}"
export LDFLAGS="${LDFLAGS:---sysroot=$SYSROOT -Wl,--import-memory,--export-memory,--max-memory=67108864,--export=__stack_pointer,--export=__stack_low}"

This way you could modify them at the time you call the compile without having to edit the script, like this:
WASMTIME=$HOME/.cargo/bin/wasmtime ./compile_lmbench.sh

And if you later want to move it to the Makefile to adhere to the build contract style we talked about in Issue 10

@m-hemmings m-hemmings requested a review from rennergade July 23, 2025 22:17
@rennergade
Copy link
Contributor

@m-hemmings so basically we have to build libtirpc.a with wasm-clang, then combine that lib with the sysroot into a new sysroot and then build lmbench.

lmbench should build somewhat properly on it's own once that sysroot is created and has its own Makefile/output folder for binaries once that step is completed.


echo "[INFO] Moving .o files to sysroot merge_tmp..."

mkdir -p /home/lind/lind-wasm/src/glibc/sysroot/lib/wasm32-wasi/merge_tmp
Copy link
Contributor

Choose a reason for hiding this comment

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

@m-hemmings this is where the sysroot stuff comes into play, I like your overlay idea but i'm not sure runbin and I completely understand it

Copy link
Member

Choose a reason for hiding this comment

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

@rennergade The idea should be that the app does all it needs to in its own context and then the tooling script moves what needs to be moved. So I wonder, could this merge be done in the app's own folders and then have the merged file be placed in the sysroot_overlay folder with the same folder structure it would need if it went to sysroot? or is it required that it be done in situ in the actual sysroot?
The original idea was that the app would not modify the actual sysroot at all, but we can revisit that if it doesn't fit

#!/bin/bash
set +e

CLANG="/home/lind/lind-wasm/clang+llvm-16.0.4-x86_64-linux-gnu-ubuntu-22.04/bin/clang"
Copy link
Contributor

Choose a reason for hiding this comment

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

@robinyuan1002 can we not call the lmbench Makefile to build it? not the toplevel one but the one in src?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes we can, but I think I can create a new Makefile just for compiling tests.

Copy link
Contributor

Choose a reason for hiding this comment

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

If the one provided works why would we want to add a different one?

@robinyuan1002
Copy link
Contributor Author

If we want to create a new Makefile should we delete the old one in the lmbench directory?

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.

3 participants