Skip to content

Conversation

@mstorsjo
Copy link
Member

@mstorsjo mstorsjo commented Nov 7, 2025

It turns out that rc.exe doesn't interpret integer literals as octal numbers - but GNU windres does. Previously, llvm-rc did interpret them as octal.

Fix the issue by stripping away the leading zeros during tokenization. The alternative (which would be somewhat cleaner, as visible in tokenizer.test) would be to retain them in the RCToken object, but strip them out before calling
StringRef::getAsInteger. Alternatively to handle the radix detection locally in llvm-rc code and not rely on getAsInteger to autodetect it. Both of those solutions require propagating the IsWindres flag so that it is available within RCToken, or at least when calling RCToken::intValue().

Fixes: #144723

… mode

It turns out that rc.exe doesn't interpret integer literals as
octal numbers - but GNU windres does. Previously, llvm-rc did
interpret them as octal.

Fix the issue by stripping away the leading zeros during
tokenization. The alternative (which would be somewhat cleaner,
as visible in tokenizer.test) would be to retain them in the
RCToken object, but strip them out before calling
StringRef::getAsInteger. Alternatively to handle the radix
detection locally in llvm-rc code and not rely on getAsInteger
to autodetect it. Both of those solutions require propagating
the IsWindres flag so that it is available within RCToken, or at
least when calling RCToken::intValue().

Fixes: llvm#144723
Copy link
Member

@aganea aganea left a comment

Choose a reason for hiding this comment

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

LGTM. Does this deserve a release notes entry?

@mstorsjo
Copy link
Member Author

mstorsjo commented Nov 7, 2025

LGTM. Does this deserve a release notes entry?

Not sure; I guess this is a fairly obscure bugfix...

What do you think about backporting this to 21.x? It's a quite safe change to make, but we're also quite late in the 21.x cycle.

@aganea
Copy link
Member

aganea commented Nov 8, 2025

LGTM. Does this deserve a release notes entry?

Not sure; I guess this is a fairly obscure bugfix...

What do you think about backporting this to 21.x? It's a quite safe change to make, but we're also quite late in the 21.x cycle.

Yes we can port it.

@mstorsjo mstorsjo merged commit 3673cc7 into llvm:main Nov 8, 2025
11 checks passed
@mstorsjo mstorsjo deleted the llvm-rc-no-octal branch November 8, 2025 20:24
@mstorsjo mstorsjo added this to the LLVM 21.x Release milestone Nov 8, 2025
@github-project-automation github-project-automation bot moved this to Needs Triage in LLVM Release Status Nov 8, 2025
@mstorsjo
Copy link
Member Author

mstorsjo commented Nov 8, 2025

/cherry-pick 3673cc7

@llvmbot
Copy link
Member

llvmbot commented Nov 8, 2025

/pull-request #167174

@llvmbot llvmbot moved this from Needs Triage to Done in LLVM Release Status Nov 8, 2025
dyung pushed a commit to llvmbot/llvm-project that referenced this pull request Nov 12, 2025
… mode (llvm#166915)

It turns out that rc.exe doesn't interpret integer literals as octal
numbers - but GNU windres does. Previously, llvm-rc did interpret them
as octal.

Fix the issue by stripping away the leading zeros during tokenization.
The alternative (which would be somewhat cleaner, as visible in
tokenizer.test) would be to retain them in the RCToken object, but strip
them out before calling
StringRef::getAsInteger. Alternatively to handle the radix detection
locally in llvm-rc code and not rely on getAsInteger to autodetect it.
Both of those solutions require propagating the IsWindres flag so that
it is available within RCToken, or at least when calling
RCToken::intValue().

Fixes: llvm#144723
(cherry picked from commit 3673cc7)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

llvm-rc fails to parse FILEVERSION 16bit values

3 participants