groovy
  1. groovy
  2. GROOVY-5063

Cannot set "-Werror" javac option when using Groovyc ant task.

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.8.5, 2.0-beta-2
    • Component/s: Compiler
    • Labels:
      None
    • Number of attachments :
      0

      Description

      When trying to configure the joint compiler to treat java compile warnings as errors I tried to set the following javac args:

      • -Xlint:all
      • -Werror

      I found that -Xlint:all worked, but -Werror gave me an error saying that it was an unrecognised option. After some digging it seems that the joint compiler prefixes all options bound for javac with -F, which means the lint option was transformed to "-FXlint:all" but the -Werror option didn't get this same transformation. If I manually added the "-F" making it "-FWerror" everything worked as it should.

      I went looking for whereabouts this prefixing gets applied to try and determine why it wasn't happening to "-Werror" but couldn't find it.

        Activity

        Show
        Roshan Dawrani added a comment - -X options become -FX in joint compilation here: https://github.com/groovy/groovy-core/blob/GROOVY_1_9_BETA_3/src/main/org/codehaus/groovy/ant/Groovyc.java#L751
        Hide
        Roshan Dawrani added a comment -

        javac -help doesn't show -W options. Is "-Werror" an officially supported option?

        http://weblogs.java.net/blog/tball/archive/2006/11/get_medieval_on.html calls 'Werror' a hidden option.

        Although, it should probably do no harm to allow it if Ant allows it.

        Show
        Roshan Dawrani added a comment - javac -help doesn't show -W options. Is "-Werror" an officially supported option? http://weblogs.java.net/blog/tball/archive/2006/11/get_medieval_on.html calls 'Werror' a hidden option. Although, it should probably do no harm to allow it if Ant allows it.
        Hide
        Roshan Dawrani added a comment -

        If no one has any objection, I can add jointOptions.add(optionStr.replace("-W", "-FW")); to support -Werror in joint compilation.

        Show
        Roshan Dawrani added a comment - If no one has any objection, I can add jointOptions.add(optionStr.replace("-W", "-FW")); to support -Werror in joint compilation.
        Hide
        blackdrag blackdrag added a comment -

        what -W options do exist?

        Show
        blackdrag blackdrag added a comment - what -W options do exist?
        Hide
        Roshan Dawrani added a comment -

        >> what -W options do exist?

        Looking at JDK make files, I can see options like:

        -Wno-unused 
        -Wno-parentheses
        -Werror
        

        But why? Does the decision depend on what options are there? Or is it more like being a pass through to Javac like Ant, and not bother about the specifics of the options?

        Show
        Roshan Dawrani added a comment - >> what -W options do exist? Looking at JDK make files, I can see options like: -Wno-unused -Wno-parentheses -Werror But why? Does the decision depend on what options are there? Or is it more like being a pass through to Javac like Ant, and not bother about the specifics of the options?
        Hide
        blackdrag blackdrag added a comment -

        The amount was interesting to me to see if we do that for a general thing or for just a few options. -X is used with in many combinations, so it is really worth it. -W options is partly undocumented and kind of non-official. Also there exists a way to get this working.

        Roshan and Luke, you guys think this is really worth it?

        Show
        blackdrag blackdrag added a comment - The amount was interesting to me to see if we do that for a general thing or for just a few options. -X is used with in many combinations, so it is really worth it. -W options is partly undocumented and kind of non-official. Also there exists a way to get this working. Roshan and Luke, you guys think this is really worth it?
        Hide
        blackdrag blackdrag added a comment -

        One more thing to say... I actually think this kind of forwarding is a bit problematic for us. Adding -W as a forwarding means we cannot use it ourselves. I actually would have been against the -X version, but I missed that issue I think. The only reason I am considering this here at all, is because we have -X. Which makes it a bit a weak argumentation chain for me.

        Show
        blackdrag blackdrag added a comment - One more thing to say... I actually think this kind of forwarding is a bit problematic for us. Adding -W as a forwarding means we cannot use it ourselves. I actually would have been against the -X version, but I missed that issue I think. The only reason I am considering this here at all, is because we have -X. Which makes it a bit a weak argumentation chain for me.
        Hide
        Luke Daley added a comment -

        Jochen: so are you proposing that we do nothing and require users to prefix the args themselves?

        Show
        Luke Daley added a comment - Jochen: so are you proposing that we do nothing and require users to prefix the args themselves?
        Hide
        blackdrag blackdrag added a comment -

        I am not yet proposing, I want more to see your opinions on this

        Show
        blackdrag blackdrag added a comment - I am not yet proposing, I want more to see your opinions on this
        Hide
        Luke Daley added a comment -

        Anything short of being able to just specify the same args I would specify to javac is going to be confusing. It would just be implementation detail leaking through.

        Show
        Luke Daley added a comment - Anything short of being able to just specify the same args I would specify to javac is going to be confusing. It would just be implementation detail leaking through.
        Hide
        blackdrag blackdrag added a comment -

        but two things speak against that argumentation:
        (1) not all java compilers support that option
        (2) you give this option to the groovy compiler in the first place, not the java compiler. Controlling the java compiler is supposed to work with -F and -J.

        Show
        blackdrag blackdrag added a comment - but two things speak against that argumentation: (1) not all java compilers support that option (2) you give this option to the groovy compiler in the first place, not the java compiler. Controlling the java compiler is supposed to work with -F and -J.
        Hide
        Luke Daley added a comment -

        Not sure that (1) is relevant, if the Java compiler doesn't support it should complain and not Groovy.

        As for (2), how so? If I nest a <javac> element I would expect as a user for it to be the same as a regular <javac> element. The fact that it behaves differently because it is nested inside <groovyc> is not obvious at all (and shouldn't be).

        Show
        Luke Daley added a comment - Not sure that (1) is relevant, if the Java compiler doesn't support it should complain and not Groovy. As for (2), how so? If I nest a <javac> element I would expect as a user for it to be the same as a regular <javac> element. The fact that it behaves differently because it is nested inside <groovyc> is not obvious at all (and shouldn't be).
        Hide
        Roshan Dawrani added a comment -

        I also happen to think that Groovy should not block -W options in reaching javac from nested <javac> elements.

        It seems inconsistent that in joint compilation, a user can pass one option to javac as <compilerarg value="-Xlint:all">, and for other, he needs to do <compilerarg value="-FWerror">.

        Show
        Roshan Dawrani added a comment - I also happen to think that Groovy should not block -W options in reaching javac from nested <javac> elements. It seems inconsistent that in joint compilation, a user can pass one option to javac as <compilerarg value="-Xlint:all">, and for other, he needs to do <compilerarg value="-FWerror">.
        Hide
        blackdrag blackdrag added a comment -

        Sorry, guys, I did totally oversee that this is for the ant task, not for the command line.

        But then there should be actually a more general approach. Not only the -W and -X options should be given through, but everything. For example the -g variants. Only problem in that is we would have to check for an assignment, to then use -J, or -F if there is none. The Jikes compiler for example has +K options. Though I think the javac element we have does not support a jikes in fork mode.

        What do you think Roshan, Luke?

        Show
        blackdrag blackdrag added a comment - Sorry, guys, I did totally oversee that this is for the ant task, not for the command line. But then there should be actually a more general approach. Not only the -W and -X options should be given through, but everything. For example the -g variants. Only problem in that is we would have to check for an assignment, to then use -J, or -F if there is none. The Jikes compiler for example has +K options. Though I think the javac element we have does not support a jikes in fork mode. What do you think Roshan, Luke?
        Hide
        Luke Daley added a comment -

        I guess there's not many other options than just amending the list as new args are found.

        Show
        Luke Daley added a comment - I guess there's not many other options than just amending the list as new args are found.
        Hide
        Roshan Dawrani added a comment -

        +1 to Luke's suggestion. Otherwise it is un-necessarily stuck holding even the options that we know about.

        Show
        Roshan Dawrani added a comment - +1 to Luke's suggestion. Otherwise it is un-necessarily stuck holding even the options that we know about.
        Hide
        blackdrag blackdrag added a comment -

        ok then.. Roshan, you want to take the issue?

        Show
        blackdrag blackdrag added a comment - ok then.. Roshan, you want to take the issue?
        Hide
        Roshan Dawrani added a comment -

        Done. In joint compilation, -W options are now passed to javac like -X options.

        Show
        Roshan Dawrani added a comment - Done. In joint compilation, -W options are now passed to javac like -X options.
        Hide
        Luke Daley added a comment - - edited

        Nice one Roshan, thanks.

        Show
        Luke Daley added a comment - - edited Nice one Roshan, thanks.

          People

          • Assignee:
            Roshan Dawrani
            Reporter:
            Luke Daley
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: