Previously HWCAP_ATOMIC and others were being used before checking if
they were defined. This moves up all the ifndef checks to define these
macros if they are not yet defined.
Details
Details
- Reviewers
ilinpv smeenai - Commits
- rG70ab8e8ad99e: [compiler-rt] Move up undefined macro checks
Diff Detail
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Comment Actions
What was the original reason for this particular change? Because after this, with clang and compiler-rt 16, I now see a whole bunch of:
In file included from /home/dim/src/freebsd/llvm-16-update/contrib/llvm-project/compiler-rt/lib/builtins/cpu_model.c:1019: In file included from /home/dim/obj/home/dim/src/freebsd/llvm-16-update/arm64.aarch64/tmp/usr/include/sys/auxv.h:35: In file included from /home/dim/obj/home/dim/src/freebsd/llvm-16-update/arm64.aarch64/tmp/usr/include/machine/elf.h:36: In file included from /home/dim/obj/home/dim/src/freebsd/llvm-16-update/arm64.aarch64/tmp/usr/include/sys/elf32.h:34: /home/dim/obj/home/dim/src/freebsd/llvm-16-update/arm64.aarch64/tmp/usr/include/sys/elf_common.h:980:9: error: 'AT_HWCAP' macro redefined [-Werror,-Wmacro-redefined] #define AT_HWCAP 25 /* CPU feature flags. */ ^ /home/dim/src/freebsd/llvm-16-update/contrib/llvm-project/compiler-rt/lib/builtins/cpu_model.c:843:9: note: previous definition is here #define AT_HWCAP 16 ^ In file included from /home/dim/src/freebsd/llvm-16-update/contrib/llvm-project/compiler-rt/lib/builtins/cpu_model.c:1019: In file included from /home/dim/obj/home/dim/src/freebsd/llvm-16-update/arm64.aarch64/tmp/usr/include/sys/auxv.h:35: /home/dim/obj/home/dim/src/freebsd/llvm-16-update/arm64.aarch64/tmp/usr/include/machine/elf.h:95:9: error: 'HWCAP_FP' macro redefined [-Werror,-Wmacro-redefined] #define HWCAP_FP 0x00000001 ^ /home/dim/src/freebsd/llvm-16-update/contrib/llvm-project/compiler-rt/lib/builtins/cpu_model.c:849:9: note: previous definition is here #define HWCAP_FP (1 << 0) ^ In file included from /home/dim/src/freebsd/llvm-16-update/contrib/llvm-project/compiler-rt/lib/builtins/cpu_model.c:1019: In file included from /home/dim/obj/home/dim/src/freebsd/llvm-16-update/arm64.aarch64/tmp/usr/include/sys/auxv.h:35: /home/dim/obj/home/dim/src/freebsd/llvm-16-update/arm64.aarch64/tmp/usr/include/machine/elf.h:96:9: error: 'HWCAP_ASIMD' macro redefined [-Werror,-Wmacro-redefined] #define HWCAP_ASIMD 0x00000002 ^ ...
because it seems to me that checking whether a macro is defined should be done *after* including any system header where such a macro _could_ possibly be defined, not the other way around?
I think the order should instead be:
- include system headers that potentially defined HWCAP_xxx
- block with #ifndef HWCAP_xxx ... #define HWCAP_xxx ...
- block with inline functions actually using HWCAP_xxx
Comment Actions
I think the order should instead be:
- include system headers that potentially defined HWCAP_xxx
- block with #ifndef HWCAP_xxx ... #define HWCAP_xxx ...
- block with inline functions actually using HWCAP_xxx
Absolutely correct. I think system headers includes
#if defined(__has_include) #if __has_include(<sys/auxv.h>) #include <sys/auxv.h> #if __has_include(<asm/hwcap.h>) #include <asm/hwcap.h> #if defined(__ANDROID__) #include <string.h> #include <sys/system_properties.h> #elif defined(__Fuchsia__) #include <zircon/features.h> #include <zircon/syscalls.h> #endif
was moved after #ifndef HWCAP_xxx by mistake. Originally AT_HWCAP and HWCAP_ATOMICS were used before #ifndef HWCAP_xxx ... #define HWCAP_xxx ...