Bug 63874 - Ant regression breaks javac openjfx build
Summary: Ant regression breaks javac openjfx build
Alias: None
Product: Ant
Classification: Unclassified
Component: Core tasks (show other bugs)
Version: 1.10.7
Hardware: PC Linux
: P2 regression (vote)
Target Milestone: 1.10.8
Assignee: Ant Notifications List
Depends on:
Reported: 2019-10-22 18:51 UTC by Ilya Lipnitskiy
Modified: 2019-10-24 04:57 UTC (History)
0 users

Error log from ant 1.10.7 (52.20 KB, text/x-log)
2019-10-22 18:51 UTC, Ilya Lipnitskiy
Success log with ant 1.10.6 (52.14 KB, text/x-log)
2019-10-22 18:52 UTC, Ilya Lipnitskiy
build.xml excerpt (1.39 KB, text/xml)
2019-10-23 04:51 UTC, Ilya Lipnitskiy

Note You need to log in before you can comment on or make changes to this bug.
Description Ilya Lipnitskiy 2019-10-22 18:51:38 UTC
Created attachment 36852 [details]
Error log from ant 1.10.7

For some reason, javac command line argument files don't work with ant 1.10.7 when building Java openjfx. See attachment, or:
1. https://bugs.openjdk.java.net/browse/JDK-8231316
2. https://bugs.archlinux.org/task/64055

javac unexpectedly fails with:

[javac] error: invalid flag: @/home/username/work/build/java-openjfx/repos/extra-x86_64/src/rt-13+14/build/compile.args

The cmd line argument file is well formed and the path is correct.

Downgrading to ant 1.10.6 fixes the problem.
Comment 1 Ilya Lipnitskiy 2019-10-22 18:52:06 UTC
Created attachment 36853 [details]
Success log with ant 1.10.6
Comment 2 Jaikiran Pai 2019-10-23 03:59:37 UTC
I remember there was a change in Ant, with code involving this. Let me see if we caused some unexpected regression there.
Comment 3 Jaikiran Pai 2019-10-23 04:01:19 UTC
Is there a build.xml file to quickly reproduce this?
Comment 4 Ilya Lipnitskiy 2019-10-23 04:51:18 UTC
Created attachment 36854 [details]
build.xml excerpt

I don't have the time to minimize the build.xml at this point. However, if it helps, the problematic invocation of javac is described by the attached excerpt. The variables should be evident in the attached log.
Comment 5 Ilya Lipnitskiy 2019-10-23 17:14:00 UTC
By examining the code in src/main/org/apache/tools/ant/taskdefs/compilers/JavacExternal.java, it looks like prior to commit 15fcc941e01, executeExternalCompile() was called with cmd.size(), but in current code it is called with the index of the first non J option after reshuffling the command line arguments, not cmd.size(). Seems like a problem.

Moreover, the logic that looks at firstFileName in executeExternalCompile() is only triggered when the length of the command like is greater than COMMAND_LINE_LIMIT, which is 4KB on POSIX systems. Sounds like a test case is needed for long command lines to cover this logic.
Comment 6 Ilya Lipnitskiy 2019-10-23 18:26:31 UTC
Also based on https://docs.oracle.com/javase/7/docs/technotes/tools/windows/javac.html#commandlineargfile: "Use of the '@' character to recursively interpret files is not supported." So the whole changeset from https://github.com/apache/ant/pull/98 probably needs to be reworked to make sure arguments that start with '@' don't get put into commandline arg files.
Comment 7 Ilya Lipnitskiy 2019-10-23 23:58:00 UTC
Should be fixed by https://github.com/apache/ant/pull/105!
Comment 8 Jaikiran Pai 2019-10-24 04:57:36 UTC
The patch has been applied upstream. This fix will be available in 1.10.8 of Ant. In the meantime, the Ant nightly build containing this fix can be used for testing this change https://builds.apache.org/job/Ant_Nightly/lastSuccessfulBuild/artifact/distribution/.