Bug 63874

Summary: Ant regression breaks javac openjfx build
Product: Ant Reporter: Ilya Lipnitskiy <ilya.lipnitskiy>
Component: Core tasksAssignee: Ant Notifications List <notifications>
Status: RESOLVED FIXED    
Severity: regression    
Priority: P2    
Version: 1.10.7   
Target Milestone: 1.10.8   
Hardware: PC   
OS: Linux   
Attachments: Error log from ant 1.10.7
Success log with ant 1.10.6
build.xml excerpt

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/.