Skip to content

Add godbolt-minimal CMake preset for browser-based compiler environments#7063

Merged
hkaiser merged 1 commit intoTheHPXProject:masterfrom
shivansh023023:feat/godbolt-minimal-preset
Mar 20, 2026
Merged

Add godbolt-minimal CMake preset for browser-based compiler environments#7063
hkaiser merged 1 commit intoTheHPXProject:masterfrom
shivansh023023:feat/godbolt-minimal-preset

Conversation

@shivansh023023
Copy link
Copy Markdown
Contributor

Fixes # — N/A (new feature)

Proposed Changes

  • Add godbolt-minimal configure preset to CMakePresets.json with 8 cache variables optimized for browser-based sandboxed environments (Compiler Explorer / Godbolt): HPX_WITH_MALLOC=system, HPX_WITH_NETWORKING=OFF, HPX_WITH_TESTS=OFF, HPX_WITH_EXAMPLES=OFF, HPX_WITH_DOCUMENTATION=OFF, HPX_WITH_STATIC_LINKING=ON, HPX_WITH_FETCH_ASIO=ON, CMAKE_BUILD_TYPE=Release.
  • Add corresponding godbolt-minimal build preset.
  • This enables a one-command reproducible build (cmake --preset godbolt-minimal) that produces the minimal static HPX libraries required for integration with Compiler Explorer.

Any background context you want to provide?

As part of the GSoC 2026 effort to integrate HPX into Compiler Explorer, we identified a specific combination of CMake flags required to produce a minimal, single-node static build suitable for sandboxed web execution. This preset encodes the exact configuration that was verified locally against HPX 2.0.0 with GCC 13.3.0 (C++20), producing all 12 expected static libraries (libhpx_wrap.a, libhpx.a, libhpx_init.a, libhpx_core.a, etc.) and the critical hpx/hpx_main.hpp header.

Key design decisions:

  • HPX_WITH_MALLOC=system — Removes the tcmalloc/jemalloc dependency to reduce binary size and avoid allocator collisions in the Godbolt sandbox.
  • HPX_WITH_NETWORKING=OFF — Godbolt is single-node; all parcelport code (MPI, LCI, libfabric, GASNet) is unnecessary.
  • HPX_WITH_STATIC_LINKING=ON — Required by Compiler Explorer's Conan-based per-compiler binary distribution pipeline.
  • HPX_WITH_FETCH_ASIO=ON — Auto-fetches Asio, removing one external dependency for sandboxed builders.
  • HPX_WITH_DISTRIBUTED_RUNTIME=OFF was deliberately NOT set to avoid the HPX_WITH_APEX conflict; HPX_WITH_NETWORKING=OFF already disables all parcelports.

This preset follows the existing conventions in CMakePresets.json (schema v4, Ninja generator, kebab-case naming, ${sourceDir}/build/<name> binary directory pattern).

Checklist

  • I have added a new feature and have added tests to go along with it.
    • No test preset was added because HPX_WITH_TESTS=OFF in this configuration. The preset was verified by a successful local build producing all expected artifacts.
  • I have fixed a bug and have added a regression test. — N/A
  • I have added a test using random numbers — N/A

@shivansh023023 shivansh023023 requested a review from hkaiser as a code owner March 19, 2026 20:54
@StellarBot
Copy link
Copy Markdown

Can one of the admins verify this patch?

Signed-off-by: shivansh023023 <singhshivansh023@gmail.com>
@shivansh023023 shivansh023023 force-pushed the feat/godbolt-minimal-preset branch from fe6cd7b to e2c080f Compare March 19, 2026 21:10
@hkaiser
Copy link
Copy Markdown
Contributor

hkaiser commented Mar 20, 2026

FWIW, <hpx/hpx_main.hpp> is not necessary nowadays anymore as long as the application is linked against the CMake target HPX::auto_wrap_main. Not sure if this is of any help in this context.

Copy link
Copy Markdown
Contributor

@hkaiser hkaiser left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@hkaiser hkaiser merged commit 330b506 into TheHPXProject:master Mar 20, 2026
42 of 44 checks passed
GitMasterJatin added a commit to GitMasterJatin/hpx that referenced this pull request Apr 3, 2026
The existing godbolt-minimal preset (added in TheHPXProject#7063) is missing several
flags required for a correct Compiler Explorer integration:

1. Add HPX_WITH_DISTRIBUTED_RUNTIME=OFF: HPX_WITH_NETWORKING=OFF alone
   does not disable the distributed runtime -- AGAS, actions, and the
   parcelset infrastructure are still compiled, wasting ~30% build time
   and producing libraries that CE will never use.

2. Add HPX_WITH_CXX_STANDARD=20: pins the C++ standard explicitly so
   builds are deterministic across GCC/Clang versions. Uses HPX's own
   cache variable (not CMAKE_CXX_STANDARD, which HPX rejects unless
   HPX_USE_CMAKE_CXX_STANDARD is also set).

3. Add HPX_WITH_TOOLS=OFF: CE only needs libraries and headers; building
   HPX tools adds unnecessary build time.

4. Improve description: document the produced static libraries
   (libhpx_wrap.a, libhpx_init.a, libhpx.a, libhpx_core.a) and the
   required -Wl,-wrap=main linker flag for non-CMake consumers.

5. Reorder cache variables to group related flags logically:
   standard -> linking -> runtime -> dependencies -> build targets.
GitMasterJatin added a commit to GitMasterJatin/hpx that referenced this pull request Apr 8, 2026
Add a GitHub Actions workflow that builds HPX using the same flags as
the godbolt-minimal CMake preset and verifies the expected static
libraries (libhpx_wrap.a, libhpx_init.a, libhpx.a, libhpx_core.a)
are produced.

The godbolt-minimal preset was added in TheHPXProject#7063 but is not validated in
CI, meaning regressions (broken flags, missing libraries) could go
undetected. This workflow catches those issues on every PR.

The workflow:
  1. Configures with the exact flags from the godbolt-minimal preset
  2. Builds the project
  3. Asserts that all four static libraries exist in the build tree
GitMasterJatin added a commit to GitMasterJatin/hpx that referenced this pull request Apr 10, 2026
Add a GitHub Actions workflow that builds HPX using the same flags as
the godbolt-minimal CMake preset, installs it to a local prefix, then
builds and runs a minimal external hello-world program against that
installation as a crash-and-burn smoke test.

The godbolt-minimal preset was added in TheHPXProject#7063 but is not validated in
CI, meaning regressions (broken flags, missing libraries, broken CMake
export config, link-order issues) could go undetected. This workflow
catches those issues on every PR.

The workflow:
  1. Configures with the exact flags from the godbolt-minimal preset
  2. Builds the project
  3. Installs HPX to a local prefix
  4. Builds a minimal external project via find_package(HPX REQUIRED)
  5. Runs the resulting hello-world binary as a smoke test

Signed-off-by: GitMasterJatin <jatinnsharmaa7@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants