NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

toolchain/58962: clang build broken by C11 features with -std=gnu99



>Number:         58962
>Category:       toolchain
>Synopsis:       clang build broken by C11 features with -std=gnu99
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    toolchain-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Jan 06 09:45:00 +0000 2025
>Originator:     Taylor R Campbell
>Release:        current
>Organization:
The NetBSC11 Foundation
>Environment:
>Description:
The clang build is currently broken on aarch64 with the following failure:

/home/source/ab/HEAD-llvm/src/sys/dev/acpi/qcomscm.c:832:34: error: expected ')'
        if (qcscm_uefi_get_variable(sc, EFI_VAR_RTCINFO, sizeof(EFI_VAR_RTCINFO),
                                        ^
/home/source/ab/HEAD-llvm/src/sys/dev/acpi/qcomscm.c:83:38: note: expanded from macro 'EFI_VAR_RTCINFO'
#define EFI_VAR_RTCINFO                 __UNCONST(u"RTCInfo")
                                                   ^
/home/source/ab/HEAD-llvm/src/sys/dev/acpi/qcomscm.c:832:34: note: to match this '('
/home/source/ab/HEAD-llvm/src/sys/dev/acpi/qcomscm.c:83:27: note: expanded from macro 'EFI_VAR_RTCINFO'
#define EFI_VAR_RTCINFO                 __UNCONST(u"RTCInfo")
                                        ^
/home/source/ab/HEAD-llvm/src/sys/sys/cdefs.h:193:60: note: expanded from macro '__UNCONST'
#define __UNCONST(a)    ((void *)(unsigned long)(const void *)(a))
                                                              ^
/home/source/ab/HEAD-llvm/src/sys/dev/acpi/qcomscm.c:832:34: error: use of undeclared identifier 'u'
        if (qcscm_uefi_get_variable(sc, EFI_VAR_RTCINFO, sizeof(EFI_VAR_RTCINFO),
                                        ^
/home/source/ab/HEAD-llvm/src/sys/dev/acpi/qcomscm.c:83:37: note: expanded from macro 'EFI_VAR_RTCINFO'
#define EFI_VAR_RTCINFO                 __UNCONST(u"RTCInfo")
                                                  ^

This came from the Snapdragon X1E battery driver set:

https://mail-index.netbsd.org/source-changes/2024/12/30/msg154987.html

This code uses the new lexical syntax in C11 for UTF-16 string literals.  While we could adapt the code to use L"RTCInfo" instead of u"RTCInfo", which is what we have done elsewhere, from what I understand it really is the right thing to declare that this is UTF-16, for UEFI.

gcc accepts this syntax with -std=gnu99 as we currently use in the kernel; clang, however, rejects it with -std=gnu99 and requires -std=gnu11 or -std=c11 or later.

Discussion here:

https://mail-index.netbsd.org/tech-kern/2025/01/05/msg029919.html
>How-To-Repeat:
build aarch64 with clang
>Fix:
1. (not really right) change u"foo" to L"foo" here
2. build kernel with -std=gnu11 or -std=c11



Home | Main Index | Thread Index | Old Index