Skip to content

[BUILD] Fix unicode build issue. #135315

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

Merged
merged 1 commit into from
Apr 11, 2025
Merged

[BUILD] Fix unicode build issue. #135315

merged 1 commit into from
Apr 11, 2025

Conversation

harrisonGPU
Copy link
Contributor

Fix unicode build fail issue:

C4819	The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss	...\llvm-project\llvm\include\llvm\Support\Compiler.h

@llvmbot
Copy link
Member

llvmbot commented Apr 11, 2025

@llvm/pr-subscribers-llvm-support

Author: Harrison Hao (harrisonGPU)

Changes

Fix unicode build fail issue:

C4819	The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss	...\llvm-project\llvm\include\llvm\Support\Compiler.h

Full diff: https://github.com/llvm/llvm-project/pull/135315.diff

1 Files Affected:

  • (modified) llvm/include/llvm/Support/Compiler.h (+1-1)
diff --git a/llvm/include/llvm/Support/Compiler.h b/llvm/include/llvm/Support/Compiler.h
index d3772896069cc..d265d864228ca 100644
--- a/llvm/include/llvm/Support/Compiler.h
+++ b/llvm/include/llvm/Support/Compiler.h
@@ -232,7 +232,7 @@
 
 // Only enabled for clang:
 // See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99587
-// GCC may produce "warning: ‘retain’ attribute ignored" (despite
+// GCC may produce "warning: 'retain' attribute ignored" (despite
 // __has_attribute(retain) being 1).
 #if defined(__clang__) && __has_attribute(retain)
 #define LLVM_ATTRIBUTE_RETAIN __attribute__((__retain__))

@cor3ntin
Copy link
Contributor

This is #64668.
I'm not opposed to this particular change (that use of quotes seems accidental), but I would rather we make sure our source files are treated as UTF-8 in the general case.

@harrisonGPU harrisonGPU requested a review from jayfoad April 11, 2025 12:17
@harrisonGPU
Copy link
Contributor Author

Thanks. :-)

@harrisonGPU harrisonGPU merged commit e36e57b into llvm:main Apr 11, 2025
13 checks passed
@harrisonGPU harrisonGPU deleted the build-fix branch April 11, 2025 12:36
@jayfoad
Copy link
Contributor

jayfoad commented Apr 11, 2025

I see we have other non-ASCII source files in LLVM. For example just in include I found:

include/llvm/BinaryFormat/ELFRelocs/LoongArch.def:                                      C source, Unicode text, UTF-8 text
include/llvm/BinaryFormat/DXContainer.h:                                                C++ source, Unicode text, UTF-8 text
include/llvm/CodeGen/MachineOperand.h:                                                  C++ source, Unicode text, UTF-8 text
include/llvm/Support/ConvertUTF.h:                                                      C++ source, Unicode text, UTF-8 text
include/llvm/Support/AArch64BuildAttributes.h:                                          C++ source, Unicode text, UTF-8 text
include/llvm/Transforms/Scalar/SROA.h:                                                  C++ source, Unicode text, UTF-8 (with BOM) text
include/llvm/Transforms/IPO/FunctionSpecialization.h:                                   C++ source, Unicode text, UTF-8 text
include/llvm/Analysis/ConstraintSystem.h:                                               C++ source, Unicode text, UTF-8 text
include/llvm/MC/MCSubtargetInfo.h:                                                      C++ source, Unicode text, UTF-8 text
include/llvm/ADT/GenericUniformityImpl.h:                                               C++ source, Unicode text, UTF-8 (with BOM) text

I guess the Windows error depends on the exact non-ASCII characters that are used?

@harrisonGPU
Copy link
Contributor Author

I'm not sure. I just encountered this issue — even after setting 'treat warnings as errors' to false, the build still failed. So I fixed the build issue.

var-const pushed a commit to ldionne/llvm-project that referenced this pull request Apr 17, 2025
Fix unicode build fail issue:
```
C4819	The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss	...\llvm-project\llvm\include\llvm\Support\Compiler.h
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants