[clang] Disable -fdollars-in-identifiers by default (PR #135407)
Nathan Chancellor via cfe-commits
cfe-commits at lists.llvm.org
Wed Apr 16 11:54:48 PDT 2025
nathanchance wrote:
> We should disable the warning if we're preprocessing asm, which should mostly solve the issue with warnings.
Yes although the warnings from `arch/x86/include/asm/nospec-branch.h` do show up from `.c` files so that would only partially fix it.
```
In file included from drivers/gpio/gpio-brcmstb.c:5:
In file included from include/linux/gpio/driver.h:8:
In file included from include/linux/irqchip/chained_irq.h:10:
In file included from include/linux/irq.h:14:
In file included from include/linux/spinlock.h:59:
In file included from include/linux/irqflags.h:18:
In file included from arch/x86/include/asm/irqflags.h:9:
arch/x86/include/asm/nospec-branch.h:80:7: warning: '$' in identifier; did you mean to enable '-fdollars-in-identifiers'? [-Wdollar-in-identifier]
80 | movq $-1, PER_CPU_VAR(__x86_call_depth);
| ^
arch/x86/include/asm/nospec-branch.h:84:6: warning: '$' in identifier; did you mean to enable '-fdollars-in-identifiers'? [-Wdollar-in-identifier]
84 | bts $63, %rax; \
| ^
arch/x86/include/asm/nospec-branch.h:88:7: warning: '$' in identifier; did you mean to enable '-fdollars-in-identifiers'? [-Wdollar-in-identifier]
88 | movb $0xfc, %al; \
| ^
arch/x86/include/asm/nospec-branch.h:89:6: warning: '$' in identifier; did you mean to enable '-fdollars-in-identifiers'? [-Wdollar-in-identifier]
89 | shl $56, %rax; \
| ^
arch/x86/include/asm/nospec-branch.h:94:7: warning: '$' in identifier; did you mean to enable '-fdollars-in-identifiers'? [-Wdollar-in-identifier]
94 | sarq $5, PER_CPU_VAR(__x86_call_depth); \
| ^
arch/x86/include/asm/nospec-branch.h:142:6: warning: '$' in identifier; did you mean to enable '-fdollars-in-identifiers'? [-Wdollar-in-identifier]
142 | mov $(nr/2), reg; \
| ^
arch/x86/include/asm/nospec-branch.h:146:6: warning: '$' in identifier; did you mean to enable '-fdollars-in-identifiers'? [-Wdollar-in-identifier]
146 | add $(BITS_PER_LONG/8) * 2, %_ASM_SP; \
| ^
arch/x86/include/asm/nospec-branch.h:176:6: warning: '$' in identifier; did you mean to enable '-fdollars-in-identifiers'? [-Wdollar-in-identifier]
176 | add $(BITS_PER_LONG/8), %_ASM_SP; \
| ^
8 warnings generated.
```
> For the Linux kernel, does anything break other than the warnings?
Does not look like it (aside from one file that does not respect the global `-Werror` configuration and includes it regardless).
Since I already tested it, I figured I might as well report it anyways. If I add `-fdollars-in-identifiers` to `CLANG_FLAGS`, several things break because it looks like the preprocessor no longer properly expands certain macros that were used to define assembly immediate:
```
arch/x86/platform/pvh/head.S:73:11: error: unexpected token in argument list
subl $rva(1b), %ebp
^
make[6]: *** [scripts/Makefile.build:335: arch/x86/platform/pvh/head.o] Error 1
make[6]: Target 'arch/x86/platform/pvh/' not remade because of errors.
make[5]: *** [scripts/Makefile.build:461: arch/x86/platform/pvh] Error 2
ld.lld: error: undefined symbol: X86_CR0_PE
>>> referenced by wakeup_asm.S:53 (arch/x86/realmode/rm/wakeup_asm.S:53)
>>> arch/x86/realmode/rm/wakeup_asm.o:(wakeup_start)
ld.lld: error: undefined symbol: WAKEUP_HEADER_SIGNATURE
>>> referenced by wakeup_asm.S:84 (arch/x86/realmode/rm/wakeup_asm.S:84)
>>> arch/x86/realmode/rm/wakeup_asm.o:(wakeup_start)
ld.lld: error: undefined symbol: REALMODE_END_SIGNATURE
>>> referenced by wakeup_asm.S:89 (arch/x86/realmode/rm/wakeup_asm.S:89)
>>> arch/x86/realmode/rm/wakeup_asm.o:(wakeup_start)
ld.lld: error: undefined symbol: WAKEUP_BEHAVIOR_RESTORE_MISC_ENABLE
>>> referenced by wakeup_asm.S:98 (arch/x86/realmode/rm/wakeup_asm.S:98)
>>> arch/x86/realmode/rm/wakeup_asm.o:(wakeup_start)
ld.lld: error: undefined symbol: MSR_IA32_MISC_ENABLE
>>> referenced by wakeup_asm.S:103 (arch/x86/realmode/rm/wakeup_asm.S:103)
>>> arch/x86/realmode/rm/wakeup_asm.o:(wakeup_start)
>>> referenced by verify_cpu.S:97 (arch/x86/include/../kernel/verify_cpu.S:97)
>>> arch/x86/realmode/rm/trampoline_64.o:(verify_cpu)
ld.lld: error: undefined symbol: __KERNEL_DS
>>> referenced by trampoline_64.S:89 (arch/x86/realmode/rm/trampoline_64.S:89)
>>> arch/x86/realmode/rm/trampoline_64.o:(trampoline_start)
>>> referenced by reboot.S:27 (arch/x86/realmode/rm/reboot.S:27)
>>> arch/x86/realmode/rm/reboot.o:(machine_real_restart_asm)
>>> referenced by trampoline_64.S:199 (arch/x86/realmode/rm/trampoline_64.S:199)
>>> arch/x86/realmode/rm/trampoline_64.o:(pa_trampoline_compat)
>>> referenced 1 more times
ld.lld: error: undefined symbol: __KERNEL32_CS
>>> referenced by trampoline_64.S:96 (arch/x86/realmode/rm/trampoline_64.S:96)
>>> arch/x86/realmode/rm/trampoline_64.o:(trampoline_start)
>>> referenced by reboot.S:35 (arch/x86/realmode/rm/reboot.S:35)
>>> arch/x86/realmode/rm/reboot.o:(machine_real_restart_asm)
>>> referenced by trampoline_64.S:203 (arch/x86/realmode/rm/trampoline_64.S:203)
>>> arch/x86/realmode/rm/trampoline_64.o:(pa_trampoline_compat)
ld.lld: error: undefined symbol: REQUIRED_MASK0
>>> referenced by verify_cpu.S:106 (arch/x86/include/../kernel/verify_cpu.S:106)
>>> arch/x86/realmode/rm/trampoline_64.o:(verify_cpu)
>>> referenced by verify_cpu.S:107 (arch/x86/include/../kernel/verify_cpu.S:107)
>>> arch/x86/realmode/rm/trampoline_64.o:(verify_cpu)
ld.lld: error: undefined symbol: REQUIRED_MASK1
>>> referenced by verify_cpu.S:117 (arch/x86/include/../kernel/verify_cpu.S:117)
>>> arch/x86/realmode/rm/trampoline_64.o:(verify_cpu)
>>> referenced by verify_cpu.S:118 (arch/x86/include/../kernel/verify_cpu.S:118)
>>> arch/x86/realmode/rm/trampoline_64.o:(verify_cpu)
ld.lld: error: undefined symbol: SSE_MASK
>>> referenced by verify_cpu.S:124 (arch/x86/include/../kernel/verify_cpu.S:124)
>>> arch/x86/realmode/rm/trampoline_64.o:(verify_cpu)
>>> referenced by verify_cpu.S:125 (arch/x86/include/../kernel/verify_cpu.S:125)
>>> arch/x86/realmode/rm/trampoline_64.o:(verify_cpu)
ld.lld: error: undefined symbol: MSR_K7_HWCR
>>> referenced by verify_cpu.S:129 (arch/x86/include/../kernel/verify_cpu.S:129)
>>> arch/x86/realmode/rm/trampoline_64.o:(verify_cpu)
ld.lld: error: undefined symbol: TH_FLAGS_SME_ACTIVE_BIT
>>> referenced by trampoline_64.S:142 (arch/x86/realmode/rm/trampoline_64.S:142)
>>> arch/x86/realmode/rm/trampoline_64.o:(startup_32)
ld.lld: error: undefined symbol: MSR_AMD64_SYSCFG
>>> referenced by trampoline_64.S:144 (arch/x86/realmode/rm/trampoline_64.S:144)
>>> arch/x86/realmode/rm/trampoline_64.o:(startup_32)
ld.lld: error: undefined symbol: MSR_AMD64_SYSCFG_MEM_ENCRYPT_BIT
>>> referenced by trampoline_64.S:146 (arch/x86/realmode/rm/trampoline_64.S:146)
>>> arch/x86/realmode/rm/trampoline_64.o:(startup_32)
ld.lld: error: undefined symbol: MSR_EFER
>>> referenced by reboot.S:40 (arch/x86/realmode/rm/reboot.S:40)
>>> arch/x86/realmode/rm/reboot.o:(machine_real_restart_asm)
>>> referenced by trampoline_64.S:164 (arch/x86/realmode/rm/trampoline_64.S:164)
>>> arch/x86/realmode/rm/trampoline_64.o:(startup_32)
ld.lld: error: undefined symbol: CR0_STATE
>>> referenced by trampoline_64.S:181 (arch/x86/realmode/rm/trampoline_64.S:181)
>>> arch/x86/realmode/rm/trampoline_64.o:(startup_32)
ld.lld: error: undefined symbol: __KERNEL_CS
>>> referenced by trampoline_64.S:190 (arch/x86/realmode/rm/trampoline_64.S:190)
>>> arch/x86/realmode/rm/trampoline_64.o:(startup_32)
>>> referenced by trampoline_64.S:246 (arch/x86/realmode/rm/trampoline_64.S:246)
>>> arch/x86/realmode/rm/trampoline_64.o:(trampoline_start64)
ld.lld: error: undefined symbol: X86_CR4_LA57
>>> referenced by trampoline_64.S:228 (arch/x86/realmode/rm/trampoline_64.S:228)
>>> arch/x86/realmode/rm/trampoline_64.o:(trampoline_start64)
make[7]: *** [arch/x86/realmode/rm/Makefile:49: arch/x86/realmode/rm/realmode.elf] Error 1
make[7]: Target 'arch/x86/realmode/rm/realmode.bin' not remade because of errors.
make[6]: *** [arch/x86/realmode/Makefile:22: arch/x86/realmode/rm/realmode.bin] Error 2
make[6]: Target 'arch/x86/realmode/' not remade because of errors.
make[5]: *** [scripts/Makefile.build:461: arch/x86/realmode] Error 2
/tmp/entry_64_compat-eb247c.s:956:2: error: expected relocatable expression
testl $X86_EFLAGS_NT|((1) << (18))|((1) << (8)), 144(%rsp)
^
make[6]: *** [scripts/Makefile.build:335: arch/x86/entry/entry_64_compat.o] Error 1
ld.lld: error: undefined symbol: EENTER
>>> referenced by arch/x86/entry/vdso/vsgx.o:(__vdso_sgx_enter_enclave)
ld.lld: error: undefined symbol: ERESUME
>>> referenced by arch/x86/entry/vdso/vsgx.o:(__vdso_sgx_enter_enclave)
ld.lld: error: undefined symbol: SGX_ENCLAVE_RUN_RESERVED_START
>>> referenced by arch/x86/entry/vdso/vsgx.o:(__vdso_sgx_enter_enclave)
ld.lld: error: undefined symbol: SGX_ENCLAVE_RUN_RESERVED_END
>>> referenced by arch/x86/entry/vdso/vsgx.o:(__vdso_sgx_enter_enclave)
ld.lld: error: undefined symbol: EEXIT
>>> referenced by arch/x86/entry/vdso/vsgx.o:(__vdso_sgx_enter_enclave)
make[7]: *** [arch/x86/entry/vdso/Makefile:39: arch/x86/entry/vdso/vdso64.so.dbg] Error 1
ld.lld: error: undefined symbol: __NR_sigreturn
>>> referenced by arch/x86/entry/vdso/vdso32/sigreturn.o:(__kernel_sigreturn)
ld.lld: error: undefined symbol: __NR_rt_sigreturn
>>> referenced by arch/x86/entry/vdso/vdso32/sigreturn.o:(__kernel_rt_sigreturn)
drivers/firmware/efi/libstub/x86-mixed.S:162:17: error: unexpected token in argument list
movl $GDT_ENTRY(((0x0010 | 0x0080 | 0x0001 | 0x0002 | 0x0008) | 0x8000 | 0x2000), 0, 0xfffff) & 0xffffffff, (%edi,%ecx)
^
drivers/firmware/efi/libstub/x86-mixed.S:163:17: error: unexpected token in argument list
movl $GDT_ENTRY(((0x0010 | 0x0080 | 0x0001 | 0x0002 | 0x0008) | 0x8000 | 0x2000), 0, 0xfffff) >> 32, 4(%edi,%ecx)
^
make[8]: *** [scripts/Makefile.build:335: drivers/firmware/efi/libstub/x86-mixed.o] Error 1
```
https://github.com/llvm/llvm-project/pull/135407
More information about the cfe-commits
mailing list