Manual-sync mirror of chromium.googlesource.com/external/github.com/llvm/llvm-project (bare monorepo, no subtree suffix)
Find a file
Schrodinger ZHU Yifan dd6c14742b
[libc][darwin] avoid importing macros conflicting with function names in overlay mode (#171691)
MacOS SDK defines certain functions as macros in its stdio header. This
leads to problems in overlay mode.

This patch add undefs to macros that may conflict with function names in
overlay header. We don't expect to import them via overlay macro headers
anyway.

```bash
FAILED: [code=1] libc/src/__support/File/CMakeFiles/libc.src.__support.File.file.dir/file.cpp.o 
sccache /usr/bin/clang++ -DLIBC_NAMESPACE=__llvm_libc_22_0_0_git -D_DEBUG -I/Users/runner/work/llvm-project/llvm-project/libc -isystem /Users/runner/work/llvm-project/llvm-project/build/libc/include -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wno-pass-failed -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -g -std=gnu++17 -arch arm64 -I /Applications/Xcode_16.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.5.sdk/usr/include -DLIBC_QSORT_IMPL=LIBC_QSORT_QUICK_SORT -DLIBC_COPT_STRING_LENGTH_IMPL=element -DLIBC_COPT_FIND_FIRST_CHARACTER_IMPL=element -DLIBC_ADD_NULL_CHECKS -DLIBC_ERRNO_MODE=LIBC_ERRNO_MODE_DEFAULT -DLIBC_THREAD_MODE=LIBC_THREAD_MODE_PLATFORM -DLIBC_COPT_RAW_MUTEX_DEFAULT_SPIN_COUNT=100 -fpie -ffixed-point -fno-builtin -fno-exceptions -fno-lax-vector-conversions -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-rtti -ftrivial-auto-var-init=pattern -fno-omit-frame-pointer -Wall -Wextra -Werror -Wconversion -Wno-sign-conversion -Wdeprecated -Wno-c99-extensions -Wno-gnu-imaginary-constant -Wno-pedantic -Wimplicit-fallthrough -Wwrite-strings -Wextra-semi -Wnewline-eof -Wnonportable-system-include-path -Wstrict-prototypes -Wthread-safety -Wglobal-constructors -MD -MT libc/src/__support/File/CMakeFiles/libc.src.__support.File.file.dir/file.cpp.o -MF libc/src/__support/File/CMakeFiles/libc.src.__support.File.file.dir/file.cpp.o.d -o libc/src/__support/File/CMakeFiles/libc.src.__support.File.file.dir/file.cpp.o -c /Users/runner/work/llvm-project/llvm-project/libc/src/__support/File/file.cpp
In file included from /Users/runner/work/llvm-project/llvm-project/libc/src/__support/File/file.cpp:9:
/Users/runner/work/llvm-project/llvm-project/libc/src/__support/File/file.h:260:8: error: expected member name or ';' after declaration specifiers
  260 |   void clearerr_unlocked() { err = false; }
      |   ~~~~ ^
/Applications/Xcode_16.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/_stdio.h:495:30: note: expanded from macro 'clearerr_unlocked'
  495 | #define clearerr_unlocked(p)    __sclearerr(p)
      |                                 ^
/Applications/Xcode_16.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/_stdio.h:383:26: note: expanded from macro '__sclearerr'
  383 | #define __sclearerr(p)  ((void)((p)->_flags &= ~(__SERR|__SEOF)))
      |                           ^
In file included from /Users/runner/work/llvm-project/llvm-project/libc/src/__support/File/file.cpp:9:
/Users/runner/work/llvm-project/llvm-project/libc/src/__support/File/file.h:260:8: error: expected ')'
/Applications/Xcode_16.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/_stdio.h:495:30: note: expanded from macro 'clearerr_unlocked'
  495 | #define clearerr_unlocked(p)    __sclearerr(p)
      |                                 ^
/Applications/Xcode_16.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/_stdio.h:383:26: note: expanded from macro '__sclearerr'
  383 | #define __sclearerr(p)  ((void)((p)->_flags &= ~(__SERR|__SEOF)))
      |                           ^
/Users/runner/work/llvm-project/llvm-project/libc/src/__support/File/file.h:260:8: note: to match this '('
/Applications/Xcode_16.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/_stdio.h:495:30: note: expanded from macro 'clearerr_unlocked'
  495 | #define clearerr_unlocked(p)    __sclearerr(p)
      |                                 ^
/Applications/Xcode_16.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/_stdio.h:383:25: note: expanded from macro '__sclearerr'
  383 | #define __sclearerr(p)  ((void)((p)->_flags &= ~(__SERR|__SEOF)))
      |                          ^
In file included from /Users/runner/work/llvm-project/llvm-project/libc/src/__support/File/file.cpp:9:
/Users/runner/work/llvm-project/llvm-project/libc/src/__support/File/file.h:260:8: error: unknown type name '_flags'
  260 |   void clearerr_unlocked() { err = false; }
      |        ^
/Applications/Xcode_16.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/_stdio.h:495:30: note: expanded from macro 'clearerr_unlocked'
  495 | #define clearerr_unlocked(p)    __sclearerr(p)
      |                                 ^
/Applications/Xcode_16.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/_stdio.h:383:37: note: expanded from macro '__sclearerr'
  383 | #define __sclearerr(p)  ((void)((p)->_flags &= ~(__SERR|__SEOF)))
      |                                      ^
In file included from /Users/runner/work/llvm-project/llvm-project/libc/src/__support/File/file.cpp:9:
/Users/runner/work/llvm-project/llvm-project/libc/src/__support/File/file.h:260:8: error: a type specifier is required for all declarations
/Applications/Xcode_16.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/_stdio.h:495:30: note: expanded from macro 'clearerr_unlocked'
  495 | #define clearerr_unlocked(p)    __sclearerr(p)
      |                                 ^
/Applications/Xcode_16.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/_stdio.h:383:34: note: expanded from macro '__sclearerr'
  383 | #define __sclearerr(p)  ((void)((p)->_flags &= ~(__SERR|__SEOF)))
      |                                   ^
In file included from /Users/runner/work/llvm-project/llvm-project/libc/src/__support/File/file.cpp:9:
/Users/runner/work/llvm-project/llvm-project/libc/src/__support/File/file.h:260:8: error: expected ')'
/Applications/Xcode_16.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/_stdio.h:495:30: note: expanded from macro 'clearerr_unlocked'
  495 | #define clearerr_unlocked(p)    __sclearerr(p)
      |                                 ^
/Applications/Xcode_16.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/_stdio.h:383:44: note: expanded from macro '__sclearerr'
  383 | #define __sclearerr(p)  ((void)((p)->_flags &= ~(__SERR|__SEOF)))
      |                                             ^
/Users/runner/work/llvm-project/llvm-project/libc/src/__support/File/file.h:260:8: note: to match this '('
/Applications/Xcode_16.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/_stdio.h:495:30: note: expanded from macro 'clearerr_unlocked'
  495 | #define clearerr_unlocked(p)    __sclearerr(p)
      |                                 ^
/Applications/Xcode_16.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/_stdio.h:383:31: note: expanded from macro '__sclearerr'
  383 | #define __sclearerr(p)  ((void)((p)->_flags &= ~(__SERR|__SEOF)))
      |                                ^
/Users/runner/work/llvm-project/llvm-project/libc/src/__support/File/file.cpp:426:23: error: out-of-line definition of 'mode_flags' does not match any declaration in '__llvm_libc_22_0_0_git::File'
  426 | File::ModeFlags File::mode_flags(const char *mode) {
      |                       ^~~~~~~~~~
6 errors generated.
```
2025-12-11 16:29:49 -05:00
.ci [CI] Tweak wording for builds with passing tests and build errors (#171436) 2025-12-09 16:33:29 +00:00
.github [ExtractAPI] Update CODEOWNERS (#171866) 2025-12-11 18:31:56 +01:00
bolt [BOLT][BTI] Add MCPlusBuilder::insertBTI (#167329) 2025-12-11 11:58:24 +01:00
clang [CIR] Add support for runtime data member pointer access (#171510) 2025-12-11 10:19:00 -08:00
clang-tools-extra [clang-doc] Serialize the global namespace name in JSON (#171701) 2025-12-11 11:06:55 -08:00
cmake Revert "[Flang] Move builtin .mod generation into runtimes (Reapply #137828) (#169638)" 2025-12-09 22:39:41 +01:00
compiler-rt [sanitizer_common][test-only] Mark popen xfail on iossim (#171814) 2025-12-11 12:18:01 +00:00
cross-project-tests [Dexter] Adjust launch sequencing to align closer with DAP spec (#170523) 2025-12-09 11:32:09 +00:00
flang [flang][semantics] fix crash involving equivalences (#168909) 2025-12-11 09:16:09 -08:00
flang-rt [flang][cuda] Add support for allocate with device source (#171743) 2025-12-10 18:05:12 -08:00
libc [libc][darwin] avoid importing macros conflicting with function names in overlay mode (#171691) 2025-12-11 16:29:49 -05:00
libclc [libclc] use clc functions in clspv/shared/vstore_half.cl (#171770) 2025-12-11 15:41:55 +08:00
libcxx [libc++] Simplify how we install test-suite dependencies (#171504) 2025-12-11 09:10:54 -05:00
libcxxabi [libc++] Simplify how we install test-suite dependencies (#171504) 2025-12-11 09:10:54 -05:00
libsycl [libsycl] fix license link in README.md. 2025-12-01 16:34:37 -05:00
libunwind [runtimes] Modernize installation targets (#171677) 2025-12-11 09:09:37 -05:00
lld ELF: Remove stray ;. NFC 2025-12-09 22:33:01 -08:00
lldb [lldb] Add WebAssembly platform (#171507) 2025-12-11 11:12:26 -08:00
llvm [FunctionLoweringInfo] Use KnownBits::intersectWith. NFC (#171893) 2025-12-11 13:21:02 -08:00
llvm-libgcc
mlir [MLIR][Vector] Add unroll pattern for vector.constant_mask (#171518) 2025-12-11 13:16:55 -08:00
offload [OpenMP][Offload] Continue to update libomptarget debug messages (#170425) 2025-12-10 16:18:01 +01:00
openmp Revert "[Flang] Move builtin .mod generation into runtimes (Reapply #137828) (#169638)" 2025-12-09 22:39:41 +01:00
orc-rt [orc-rt] Add ControllerAccess interface. (#169598) 2025-11-26 14:53:00 +11:00
polly [SCEVExp] Get DL from SE, strip constructor arg (NFC) (#171823) 2025-12-11 14:26:47 +00:00
runtimes Revert "[Flang] Move builtin .mod generation into runtimes (Reapply #137828) (#169638)" 2025-12-09 22:39:41 +01:00
third-party [benchmark][NFC] Update cc_binary load (#169710) 2025-12-01 10:00:53 -06:00
utils/bazel [bazel] Port c22d82a1d4 (#171885) 2025-12-11 11:36:08 -08:00
.clang-format Enforce Unix line endings for Clang/LLVM/MLIR projects (#161460) 2025-10-02 06:09:12 -07:00
.clang-format-ignore Add empty top level .clang-format-ignore (#136022) 2025-04-16 15:48:30 -07:00
.clang-tidy Add default empty header filter regex to root .clang-tidy (#167386) 2025-11-11 01:36:25 +03:00
.git-blame-ignore-revs [clang-tidy][NFC] Add clang-tidy formatting commit to .git-blame-ignore-revs (#167126) 2025-11-20 21:42:10 +08:00
.gitattributes [libclang/python] Enable packaging clang python bindings (#125806) 2025-11-24 17:21:24 -08:00
.gitignore [llvm][nfc] Ignore OpenAI Codex artifacts (#162481) 2025-11-25 09:32:55 +00:00
.mailmap [mailmap] Update my name 2025-04-14 16:54:14 +08:00
CODE_OF_CONDUCT.md
CONTRIBUTING.md [www][docs] Remove last mentions of IRC (#139076) 2025-05-08 09:40:33 -04:00
LICENSE.TXT
pyproject.toml [lldb] Configure pyright to the documented minimum python version (#162952) 2025-11-20 10:30:22 -08:00
README.md
SECURITY.md

The LLVM Compiler Infrastructure

OpenSSF Scorecard OpenSSF Best Practices libc++

Welcome to the LLVM project!

This repository contains the source code for LLVM, a toolkit for the construction of highly optimized compilers, optimizers, and run-time environments.

The LLVM project has multiple components. The core of the project is itself called "LLVM". This contains all of the tools, libraries, and header files needed to process intermediate representations and convert them into object files. Tools include an assembler, disassembler, bitcode analyzer, and bitcode optimizer.

C-like languages use the Clang frontend. This component compiles C, C++, Objective-C, and Objective-C++ code into LLVM bitcode -- and from there into object files, using LLVM.

Other components include: the libc++ C++ standard library, the LLD linker, and more.

Getting the Source Code and Building LLVM

Consult the Getting Started with LLVM page for information on building and running LLVM.

For information on how to contribute to the LLVM project, please take a look at the Contributing to LLVM guide.

Getting in touch

Join the LLVM Discourse forums, Discord chat, LLVM Office Hours or Regular sync-ups.

The LLVM project has adopted a code of conduct for participants to all modes of communication within the project.