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

Fix Bugzilla Issue 24504 - ImportC: Enum declarations with a mixture … #16385

Open
wants to merge 1 commit into
base: stable
Choose a base branch
from

Conversation

just-harry
Copy link
Contributor

…of int and uint literal values cause errors, when targeting Windows, when debug info generation is enabled.


The value of a C enum's member can be a CastExp instead of an IntegerExp, causing these calls to toInteger to emit an error.
So instead, if the value is a CastExp we make an IntegerExp out of it and go about as normal from there.

@RazvanN7
Copy link
Contributor

I think that it's required for 'issue' to be spelled with a capital I so that the bot can pick it up. From the unittests of dlang bot I see that the combination of 'Bugzilla issue' is not present.

@just-harry just-harry changed the title Fix Bugzilla issue 24504 - ImportC: Enum declarations with a mixture … Fix Bugzilla Issue 24504 - ImportC: Enum declarations with a mixture … Apr 16, 2024
@just-harry
Copy link
Contributor Author

just-harry commented Apr 17, 2024

Maybe dlang-bot will pick it up if another comment is made?

EDIT: It didn't

@RazvanN7
Copy link
Contributor

@just-harry The PR title doesn't matter. Also, comments don't matter. The only thing that is inspected by the bot is the commit message which needs to contain "Fix Bugzilla Issue 24504" (or some other combination, but this surely will work).

@@ -0,0 +1,7 @@
// REQUIRED_ARGS: -os=windows -g
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you add -c here as well, the macOS CI failures seem to resulting from a missing main function. I know this is a compilable test and that shouldn't matter, but it would be good to rule out.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah okay—that's it pushed now

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like the same issue with -c:

2024-04-19T05:02:32.0668560Z  ... compilable/test24504.c         -c -os=windows -g ()
2024-04-19T05:02:32.0673260Z ==============================
2024-04-19T05:02:32.0722390Z Test 'compilable/test24504.c' failed. The logged output:
2024-04-19T05:02:32.0729000Z /Users/runner/work/dmd/dmd/generated/osx/release/64/dmd -conf= -m64 -Icompilable -c -os=windows -g  -od/Users/runner/work/dmd/dmd/compiler/test/test_results/compilable -of/Users/runner/work/dmd/dmd/compiler/test/test_results/compilable/test24504_0.o  -c compilable/test24504.c 
2024-04-19T05:02:32.0772720Z ld: Undefined symbols:
2024-04-19T05:02:32.0843160Z   _main, referenced from:
2024-04-19T05:02:32.0887700Z       <initial-undefines>
2024-04-19T05:02:32.0890780Z clang: error: linker command failed with exit code 1 (use -v to see invocation)
2024-04-19T05:02:32.0899230Z Error: C preprocess command clang failed for file compilable/test24504.c, exit status 1

Would a DISABLED: osx be acceptable?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

It's now disabled on macOS. It works on FreeBSD so it should work on macOS, barring the preprocessor somehow getting the linker involved.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds more like there's a problem with the Mac CI not handling the "compilable" directory properly.

There are a lot of files in compilable that do not have main()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mhm, the same issue happened with the test for #16399 (comment)—it seems related to the presence of -os=windows on the command-line


auto valueExp = sf.value();
if (auto castExp = valueExp.isCastExp())
valueExp = new IntegerExp(castExp.loc, castExp.e1.toInteger(), castExp.type);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a forcible cast which assumes its argument and the new type are workable. It would be better to find out where the CastExp is applied, and do a call to optimize() there. Further, creating an AST node for an integer just so that integer can be converted to an integer is kinda going around the horn.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better to find out where the CastExp is applied, and do a call to optimize() there.

Yeah, that's a more sensible approach (and is now pushed up). Thanks for telling me about optimize.

@WalterBright
Copy link
Member

Still no link to the bugzilla issue...

…of int and uint literal values cause errors, when targeting Windows, when debug info generation is enabled.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants