Skip to content

Redline maven plugin - #131

Draft
andreaTP wants to merge 3 commits into
bytecodealliance:mainfrom
andreaTP:redline-maven-plugin
Draft

Redline maven plugin#131
andreaTP wants to merge 3 commits into
bytecodealliance:mainfrom
andreaTP:redline-maven-plugin

Conversation

@andreaTP

Copy link
Copy Markdown
Contributor

No description provided.

@andreaTP
andreaTP force-pushed the redline-maven-plugin branch 4 times, most recently from b659f62 to 7b5388f Compare July 29, 2026 20:20
@andreaTP

Copy link
Copy Markdown
Contributor Author

on hold, not having jffi requires too much Java versions contorsionism.

Architecture:
- Bridge module uses exec:java with Generator.main() instead of the
  Maven plugin, breaking the circular dependency (plugin → redline →
  bridge → plugin)
- New redline/build-time-compiler module with RedlineGenerator that
  handles native code generation and extends generated sources with
  builder()/safeBuilder()/loadNativeCode() methods
- Maven plugin calls RedlineGenerator when <redlineTargets> is configured

Config extended with:
- redlineTargets: list of target triples for cross-compilation
- targetResourceFolder: where .native files are written

Generated module class gains (when redlineTargets configured):
- loadNativeCode(): loads platform-specific native code from resources
- builder(): automatic backend selection (native if platform + Java 25
  supported, bytecode otherwise)
- safeBuilder(): always uses bytecode compiler

NativeMachineFactory.Builder gains toInstanceBuilder() to return a
configured Instance.Builder for the generated builder() method.
RedlineTarget gains fromTriple() for target triple lookup.
- Add <redline>true</redline> shortcut to compile for all supported
  platforms (instead of listing 6 target triples)
- Add redline/it module with Maven Invoker integration test:
  - Compiles add.wat.wasm with native code for all platforms
  - Tests builder() (native), safeBuilder() (bytecode), loadNativeCode()
  - Verifies native and bytecode produce identical results
- Add logging when redline native compilation runs
@andreaTP
andreaTP force-pushed the redline-maven-plugin branch from 7b5388f to 66ffb2e Compare August 4, 2026 17:40
- Add Rust toolchain + cranelift_bridge.wasm build to ci.yaml
- Remove -Predline from release.yaml and redline.yaml
- Plugin depends directly on redline-build-time-compiler (no reflection)
- Bridge uses exec:java with GeneratorMain to break the cycle
- Generated code uses NativeMachineFactoryProvider SPI (no Panama import)
- Remove redundant targetResourceFolder from Config
- Validate target triples before compilation in RedlineGenerator
- E2E tests: JFFI (all JDKs) + Panama (JDK 25+ only)
- Restore javadoc comments on Mojo fields
@andreaTP
andreaTP force-pushed the redline-maven-plugin branch from 401e2a6 to f58545f Compare August 10, 2026 10:18

@andreaTP andreaTP left a comment

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.

a few comments

}

@Test
public void nativeCodeIsAvailable() {

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.

this is machine dependent

"var host = RedlineTarget.detectHost().orElse(null);"));

initBody.addStatement(
StaticJavaParser.parseStatement(

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.

no parseStatement + string interpolation, we should use plain JavaParser to build the desired code, is more maintainable in the longer run

<dependencies>
<dependency>
<groupId>com.github.javaparser</groupId>
<artifactId>javaparser-core</artifactId>

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.

javaparser as a dependency of the build time compiler looks a little strange, but maybe worth if it keeps complexity low.

</dependency>
<dependency>
<groupId>run.endive</groupId>
<artifactId>runtime</artifactId>

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.

isn't runtime a transitive dependency of redline?

<dependencies>
<dependency>
<groupId>run.endive</groupId>
<artifactId>redline-api-experimental</artifactId>

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.

do we need to explicitly add the api module? isn't it transitive from runner?

<configuration>
<name>endive.test.AddModule</name>
<wasmFile>src/test/resources/add.wat.wasm</wasmFile>
<interpreterFallback>WARN</interpreterFallback>

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.

un-necessary

}

@Test
public void nativeCodeIsAvailable() {

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.

this is machine dependent

<version>0.0-SNAPSHOT</version>
<packaging>jar</packaging>

<dependencies>

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.

same comments as above for the transitive deps

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