Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: --no-cpp-lines does not work if -g appears later in command line #26577

Open
mppf opened this issue Jan 21, 2025 · 3 comments
Open

[Bug]: --no-cpp-lines does not work if -g appears later in command line #26577

mppf opened this issue Jan 21, 2025 · 3 comments

Comments

@mppf
Copy link
Member

mppf commented Jan 21, 2025

Summary of Problem

Description:
I'm trying to debug something and need to look at the C code. If I compile with chpl program.chpl --savec=tmp --no-cpp-lines -g then I still see the #line directives. But, if I put the -g before --no-cpp-lines then it works.

(A bonus task related to this issue would be to come up with a better user-facing name than -cpp-lines; that can be misinterpreted as "Show me the C++ lines" but it actually means "Include #line directives so you see .chpl line numbers").

Is this issue currently blocking your progress?
No

Steps to Reproduce

Source Code:

any

Compile command:

see above

Associated Future Test(s):
TODO

Configuration Information

chpl version 2.3.0

@mppf mppf added the type: Bug label Jan 21, 2025
@bradcray
Copy link
Member

I'd consider this to be working as intended, in the sense that we typically process flags in order and permit the effects of the flags to override one another silently. For example chpl --fast --bounds-checks will do all the things --fast normally does, including disabling bounds checks, and then --bounds-checks overrides that default.

Here, -g has the effect of turning on -cpp-lines (for non-developers) as documented on the man page:

       -g, --[no-]debug
          Causes the generated C code to be compiled with debugging turned on.
          If you are trying to debug a Chapel program, this flag is virtually
          essential along with the --savec flag. This flag also turns on the
          --cpp-lines option unless compiling as a developer (for example, via
          --devel).

@bradcray
Copy link
Member

@mppf: I've been keeping this tab open to see whether you agreed with this logic or not?

@mppf mppf changed the title [Bug]: --cpp-lines does not work if -g appears later in command line [Bug]: --no-cpp-lines does not work if -g appears later in command line Jan 27, 2025
@mppf
Copy link
Member Author

mppf commented Jan 27, 2025

I'd agree with you that it's working as documented / as intended.

I think the resulting situation is confusing. I understand why --fast is connected to --bounds-checks and these two seem related to me. In contrast, --cpp-lines and -g do not seem related.

I suppose that the purpose of tying them together is that we can avoid generating #line by default (I thought we were generating it by default when using the C backend without --devel, but I seem to be mistaken in that). But, it seems to me that a better way to avoid that would be to have the compiler handle 3 states for cpp-lines rather than 2:

  • if neither --no-cpp-lines nor --cpp-lines is specified, generate #line directives if generating debug info (-g)
  • if --no-cpp-lines is specified, don't generate #line directives
  • if --cpp-lines is specified, generate #line directives.

The point of this is just that it makes the order of -g vs --no-cpp-lines not matter.

I would even posit that --fast and --bounds-checks could benefit from the same treatment, so that chpl --bounds-checks --fast something.chpl would enable bounds checks but otherwise optimize. IMO such behavior is better because the user doesn't have to be aware of hidden/implicit/subtle relationships between the flags.

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

No branches or pull requests

2 participants