Skip to content

Add a from source build script and a minimal link example - #1433

Open
matthiaskoenig wants to merge 1 commit into
sys-bio:developfrom
matthiaskoenig:feat/build-script-and-link-example
Open

matthiaskoenig wants to merge 1 commit into
sys-bio:developfrom
matthiaskoenig:feat/build-script-and-link-example

Conversation

@matthiaskoenig

Copy link
Copy Markdown
Collaborator

Adds two things that currently have to be rebuilt by hand by anyone who wants roadrunner from
source: a build script that follows the CI workflow, and the smallest complete example of linking
against the result.

scripts/build_roadrunner.sh

Runs in an empty folder and produces a usable install tree, following
.github/workflows/main.yml: clone or update the checkout, download the prebuilt
libroadrunner-deps and llvm-build release assets for the host, configure with Ninja and ccache when
present, build the install target. Python bindings are on by default, Julia and Java off; SWIG
comes from PyPI because the stable ABI needs 4.4.1 or newer and the distribution packages are older.
--help lists the options (build type, jobs, tests, plugins, prefixes, --cmake-arg, ...).

The dependency and LLVM versions are read from the workflow matrix of the checkout being built
(libroadrunner_deps_release_version, llvm_name, llvm_release_version), so the script tracks
what CI uses rather than carrying its own copy.

Two things the workflow leaves implicit are handled explicitly:

  • Asset resolution per host. The pinned dependency release no longer carries an ubuntu-24
    asset now that ubuntu-latest has moved on, so a literal transcription of the workflow 404s on
    Ubuntu 24.04. The script tries the host OS asset in the pinned release, then the manylinux_2_28
    asset from the same release, then the newest release that still has the host asset, and otherwise
    explains what to do.
  • An RTTI check on the LLVM tree. cmake/FindLLVM.cmake strips -fno-rtti from the flags
    llvm-config reports and roadrunner compiles its back end with RTTI, so an LLVM built with
    LLVM_ENABLE_RTTI=OFF fails at link time with undefined typeinfo symbols. The script asks
    llvm-config --has-rtti first and stops with that explanation instead.

scripts/link-example

A separate cmake project, not built in tree, that imports the install tree through
ImportRoadrunnerAndDependencies.cmake, links roadrunner-static::roadrunner-static and simulates
dx/dt = -k*x from an inline SBML string, printing the trajectory and checking it against
exp(-t). It needs no data files and returns non-zero when the result is wrong, so it also serves
as a check that the installed cmake package files and headers are usable from outside the build.
build_roadrunner.sh --link-example builds and runs it after installing.

Verification

On Ubuntu 24.04 x86_64, from an empty folder: fresh clone, dependency and LLVM downloads, full
build, install, then both test suites and the example.

Done: roadrunner 2.11.1 (Release)
100% tests passed, 0 tests failed out of 3505     (C++)
100% tests passed, 0 tests failed out of 15       (Python)
x(1) = 0.367879, exp(-1) = 0.367879               (link example)

The example binary needs only libm, libstdc++, libgcc_s and libc. The --source-dir,
--deps-prefix, --llvm-prefix, --no-python, --run-tests and --link-example paths were
exercised, as were the RTTI check in both directions, with a stub llvm-config reporting NO.

Note on #1432

scripts/link-example needs the fix in #1432 to configure on Linux: without it the include of
ImportRoadrunnerAndDependencies.cmake stops at find_package(zlib ...), and with only that line
fixed it stops at sbml-static. The two are best merged together. #1432 also adds a documentation
section that points at scripts/link-example; if that one is merged without this one, the pointer
should be dropped.

scripts/build_roadrunner.sh builds roadrunner from a git checkout the way
.github/workflows/main.yml does: it downloads the prebuilt libroadrunner-deps
and llvm-build release assets for the host, configures with Ninja and ccache
when they are available, and builds the install target. The dependency and LLVM
versions are read from the workflow matrix of the checkout it builds, so the
script follows the versions used in CI instead of carrying its own copy. Python
bindings are on by default, with SWIG taken from PyPI because the stable ABI
needs 4.4.1 or newer; Julia and Java are off.

Two things the workflow leaves implicit are handled explicitly. Release assets
are resolved per host, falling back to the manylinux build when the pinned
release has nothing for the host OS, which is the situation on Ubuntu 24.04 now
that the runners moved on. And the LLVM tree is checked with
llvm-config --has-rtti, because roadrunner strips -fno-rtti from the flags
llvm-config reports and compiles its back end with RTTI, so an LLVM built with
LLVM_ENABLE_RTTI=OFF would only fail much later with undefined typeinfo symbols.

scripts/link-example is a separate cmake project that links the install tree and
simulates dx/dt = -k*x, checking the result against exp(-t). It is the smallest
complete answer to "how do I use this from C++", and it doubles as a check that
the installed cmake package files and headers work from outside the build.
build_roadrunner.sh --link-example builds and runs it after installing.
@matthiaskoenig

Copy link
Copy Markdown
Collaborator Author

@luciansmith We have a ton of issues building and linking roadrunner based on the documentation. Adding a proper build script and example linking so this gets easier for people (and myself).

This branch has not been deployed

No deployments
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.

1 participant