Skip to content

Nailgun may break hermeticity for scala compilations #21146

Open
@jgranstrom

Description

@jgranstrom

Describe the bug
When compiling scala2 code with macros, the output binary may not be consistently produced when built with nailgun enabled.

Repro: https://github.com/jgranstrom/pants-macro-h-repro

With nailgun disabled it compiles consistently.

The cause is macro-references having unstable order in the compiled binary, why nailgun is causing that I don't know. This can be verified by diffing the jars produced.

I'm not sure if there's any good alternatives, but maybe it's worth considering if nailgun is worth keeping in either way.

My workaround is to disable nailgun in CI.

Pants version
2.20.0

OS
MacOS

Additional info

# With nailgun

> pants --no-local-cache --no-pantsd package jvm:jar
> mv dist/jvm/jar.jar ng1.jar
> pants --no-local-cache --no-pantsd package jvm:jar
> mv dist/jvm/jar.jar ng2.jar
> pants --no-local-cache --no-pantsd package jvm:jar
> mv dist/jvm/jar.jar ng3.jar

> sha1sum ng1.jar
20d4e1f6dbe4a1b1b1527029e53b58a82f54e81e  ng1.jar
> sha1sum ng2.jar
b66cae631870a207960195f149e47a663e321f7b  ng2.jar
> sha1sum ng3.jar
8ebdcb10f416497afa17feb473ea929ea91a792f  ng3.jar

# Without nailgun

> pants --no-process-execution-local-enable-nailgun --no-local-cache --no-pantsd package jvm:jar
> mv dist/jvm/jar.jar 0ng1.jar
> pants --no-process-execution-local-enable-nailgun --no-local-cache --no-pantsd package jvm:jar
> mv dist/jvm/jar.jar 0ng2jar
> pants --no-process-execution-local-enable-nailgun --no-local-cache --no-pantsd package jvm:jar
> mv dist/jvm/jar.jar 0ng3.jar

> sha1sum 0ng1.jar
d482f0881e1a2d4d11614310c057175eec42e3a9  0ng1.jar
> sha1sum 0ng2.jar
d482f0881e1a2d4d11614310c057175eec42e3a9  0ng2.jar
> sha1sum 0ng3.jar
d482f0881e1a2d4d11614310c057175eec42e3a9  0ng3.jar

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions