#801311 gradle hard-codes -m32 / -m64 for building binaries

Package:
src:gradle
Source:
gradle
Submitter:
Matthias Klose
Date:
2025-03-03 14:36:03 UTC
Severity:
important
Tags:
#801311#5
Date:
2015-10-08 13:38:59 UTC
From:
To:
seen when building openjfx on armhf; the openjfx build.gradle file uses:

         task compileLinuxLauncher(type: CCTask, group: "Build") {
             description = "Compiles native sources for the application
co-bundle launcher"
             matches = ".*\\.cpp"
             source file("src/main/native/launcher/linux")
             params.addAll(LINUX.launcher.ccFlags)
             compiler = LINUX.launcher.compiler
             output(file("$buildDir/native/linuxlauncher/launcherobj"))
         }
         task linkLinuxLauncher(type: LinkTask, dependsOn: compileLinuxLauncher,
group: "Build") {
             description = "Links native dynamic library for the application
co-bundle launcher"
             objectDir = file("$buildDir/native/linuxlauncher/launcherobj")
             linkParams.addAll(LINUX.launcher.linkFlags)
             linker = LINUX.launcher.linker
             lib =
file("$buildDir/classes/main/com/oracle/tools/packager/linux/JavaAppLauncher")
         }

looking into gradle ...

$ grep -rl -- '-m[36][24]' .
./subprojects/docs/src/samples/native-binaries/target-platforms/build.gradle
./subprojects/platform-native/src/integTest/groovy/org/gradle/nativeplatform/NativePlatformSamplesIntegrationTest.groovy
./subprojects/platform-native/src/integTest/groovy/org/gradle/nativeplatform/toolchain/GccToolChainCustomisationIntegrationTest.groovy
./subprojects/platform-native/src/test/groovy/org/gradle/nativeplatform/toolchain/internal/gcc/AbstractGccCompatibleToolChainTest.groovy
./subprojects/platform-native/src/test/groovy/org/gradle/nativeplatform/toolchain/internal/gcc/GccOptionsFileArgsWriterTest.groovy
./subprojects/platform-native/src/main/groovy/org/gradle/nativeplatform/toolchain/internal/gcc/AbstractGccCompatibleToolChain.java
./subprojects/platform-native/src/main/groovy/org/gradle/nativeplatform/toolchain/internal/gcc/GccOptionsFileArgsWriter.java

subprojects/docs/src/samples/native-binaries/target-platforms/build.gradle:

     toolChains {
         gcc(Gcc) {
             target("arm"){
                 cppCompiler.withArguments { args ->
                     args << "-m32"
                 }
                 linker.withArguments { args ->
                     args << "-m32"
                 }
             }
             target("sparc")
         }
     }

I have no idea if every platform has to be mentioned, isn't there a default?

All this -m32/-m64 bogus should be removed, I think we don't care about "cross
compiling".

Even for the Intel architectures this will break building things on x32.

#801311#8
Date:
2025-03-03 13:58:54 UTC
From:
To:
Hi Matthias,

In the current Gradle 4.4.1 and incoming Gradle 8.11 these arguments are
used only on the x86 architectures.

I believe that these options are actually harmless on x86. Using gradle
to build -mx32 binaries appears as an unlikely use case to me, and then
there might be ways to work around the default arguments in build
scripts.

Do you think this is still worth reporting upstream, or can this bug be
closed as either fixed in current gradle or wontfix?

Best regards,