<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/153892>153892</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            MacOS fails to configure LLVM as static
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          ZeunO8
      </td>
    </tr>
</table>

<pre>
    Trying to get LLVM compiling as a static build

The configure command I am using is

```bash
cmake -S . -B build -G Ninja \
 -DLLVM_BUILD_STATIC=ON \
 -DLLVM_LINK_LLVM_DYLIB=OFF \
 -DCMAKE_BUILD_TYPE=Release
```

Configure fails to find a bunch of required `unistd.h` symbols, as well as other header functions also.

Here is the configure output

```bash
-- The C compiler identification is AppleClang 16.0.0.16000026
-- The CXX compiler identification is AppleClang 16.0.0.16000026
-- The ASM compiler identification is AppleClang
-- Found assembler: /usr/bin/cc
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found libtool - /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool
-- Found Python3: /opt/homebrew/Frameworks/Python.framework/Versions/3.13/bin/python3.13 (found suitable version "3.13.5", minimum required is "3.8") found components: Interpreter
-- Looking for __GLIBC__
-- Looking for __GLIBC__ - not found
-- Looking for valgrind/valgrind.h
-- Looking for valgrind/valgrind.h - not found
-- Looking for FE_ALL_EXCEPT
-- Looking for FE_ALL_EXCEPT - not found
-- Looking for FE_INEXACT
-- Looking for FE_INEXACT - not found
-- Performing Test HAVE_BUILTIN_THREAD_POINTER
-- Performing Test HAVE_BUILTIN_THREAD_POINTER - Failed
-- Looking for CrashReporterClient.h
-- Looking for CrashReporterClient.h - not found
-- Performing Test HAVE_CRASHREPORTER_INFO
-- Performing Test HAVE_CRASHREPORTER_INFO - Failed
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - not found
-- Looking for pthread_create in c
-- Looking for pthread_create in c - not found
-- Looking for dlopen in dl
-- Looking for dlopen in dl - not found
-- Looking for shm_open in rt
-- Looking for shm_open in rt - not found
-- Looking for pfm_initialize in pfm
-- Looking for pfm_initialize in pfm - not found
-- Found ZLIB: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib/libz.tbd (found version "1.2.12")
-- Looking for compress2
-- Looking for compress2 - not found
-- Found LibXml2: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib/libxml2.tbd (found version "2.9.13")
-- Looking for xmlReadMemory
-- Looking for xmlReadMemory - not found
-- Looking for histedit.h
-- Looking for histedit.h - not found
-- Could NOT find LibEdit (missing: LibEdit_INCLUDE_DIRS LibEdit_LIBRARIES) 
-- Looking for arc4random
-- Looking for arc4random - not found
-- Looking for backtrace
-- Looking for backtrace - not found
-- Could NOT find Backtrace (missing: Backtrace_LIBRARY) 
-- Performing Test C_SUPPORTS_WERROR_UNGUARDED_AVAILABILITY_NEW
-- Performing Test C_SUPPORTS_WERROR_UNGUARDED_AVAILABILITY_NEW - Failed
-- Looking for __register_frame
-- Looking for __register_frame - not found
-- Looking for __deregister_frame
-- Looking for __deregister_frame - not found
-- Looking for __unw_add_dynamic_fde
-- Looking for __unw_add_dynamic_fde - not found
-- Looking for _Unwind_Backtrace
-- Looking for _Unwind_Backtrace - not found
-- Looking for getpagesize
-- Looking for getpagesize - not found
-- Looking for sysconf
-- Looking for sysconf - not found
-- Looking for getrusage
-- Looking for getrusage - not found
-- Looking for isatty
-- Looking for isatty - not found
-- Looking for futimens
-- Looking for futimens - not found
-- Looking for futimes
-- Looking for futimes - not found
-- Looking for getauxval
-- Looking for getauxval - not found
-- Looking for mallctl
-- Looking for mallctl - not found
-- Looking for mallinfo
-- Looking for mallinfo - not found
-- Looking for mallinfo2
-- Looking for mallinfo2 - not found
-- Looking for malloc_zone_statistics
-- Looking for malloc_zone_statistics - not found
-- Looking for posix_spawn
-- Looking for posix_spawn - not found
-- Looking for pread
-- Looking for pread - not found
-- Looking for sbrk
-- Looking for sbrk - not found
-- Looking for strerror_r
-- Looking for strerror_r - not found
-- Looking for strerror_s
-- Looking for strerror_s - not found
-- Looking for setenv
-- Looking for setenv - not found
-- Performing Test HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC
-- Performing Test HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC - Failed
-- Performing Test HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC
-- Performing Test HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC - Failed
-- Looking for pthread_getname_np
-- Looking for pthread_getname_np - not found
-- Looking for pthread_setname_np
-- Looking for pthread_setname_np - not found
-- Looking for pthread_get_name_np
-- Looking for pthread_get_name_np - not found
-- Looking for pthread_set_name_np
-- Looking for pthread_set_name_np - not found
-- Looking for dlopen
-- Looking for dlopen - not found
-- Looking for proc_pid_rusage
-- Looking for proc_pid_rusage - not found
-- Performing Test HAVE_CXX_ATOMICS_WITHOUT_LIB
-- Performing Test HAVE_CXX_ATOMICS_WITHOUT_LIB - Failed
-- Looking for __atomic_fetch_add_4 in atomic
-- Looking for __atomic_fetch_add_4 in atomic - not found
CMake Error at cmake/modules/CheckAtomic.cmake:59 (message):
  Host compiler appears to require libatomic, but cannot find it.
Call Stack (most recent call first):
  cmake/config-ix.cmake:487 (include)
  CMakeLists.txt:1041 (include)


-- Configuring incomplete, errors occurred!
```

When configuring as a shared library, configure completes successfully (and does find all required functions, such as `getpagesize`):

```bash
cmake -G Ninja -B build \
  -DCMAKE_INSTALL_PREFIX=llvm-macos-arm64 \
 -DCMAKE_BUILD_TYPE=Release \
  -DLLVM_BUILD_LLVM_DYLIB=ON \
 -DLLVM_BUILD_STATIC=OFF
```

Something is definitely broken with the static configure.

If I configure both shared and static, the configure also fails with the same output.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzMWU1z6rrP_zTpxkMmhJeWBYsQyG3mUtqB9Jyeu_E4iSC-dew8ttOX8-mfcUKBlkDoPZv_TKcw1k8_S3JQZIkoRTccYGwNJtZgekVKnQk5_gdKfn9zFYv0fRzJd8o3SAu0AY3m8x93KBF5QZlZJQoRpDTRNEFxSVlqOZ7leFEGKBF8TTelNN_ynPAUhYjkqFRGj6oaaA2d-i8mKrMcL8nJM6DOCtmoM6kZUecvtKD8X4KsgW85HupMjRF48hjOp3gVeVHoW73p_eKLfB4u_sbVt-mveTgxkCDYY_w77-_ZliT69TCzetMlMCAKDs2qrfR3rqwJZcrEYk15igiKS55kSKyRhP8rqYQUWUOn5FTp1M6soYPUex4LpizXN7F6BcbMp9AZSJQBSUGidckTTQVXiDAl7HrLW5CAqEL6UyRFqYtSN4eu00Em7P72dEAimgLXdE0TYugNm1cUDHxG-AZ1h7ZjO3Z36DiO4w4PCJ6e_pTCW91dRlGrBKI0wVQK8piBtHoestygVNJyg5hyyw2SpEZOQUOizQN04KY3CRHla3EBBHVQKjjUSD-D5BmthUSvQj5_1mi0AXWQeqZFAenJrdAaiC4lqHbEJ1sOgIfhP-laE6jNuQOdJvcsd2K5kzM-7vVPe9mA-WRWfdSMxloIhjrGCPM0bB8OZbnBUyJSsElRWG7gC66Ba7M8hRdgogBjcCQESzJC9_gprEnJtP2W6A_ZF_e2Wx5a8fCuM8F721iIQltukIkcYgmvlhsEkuRggmd2qbH2-mPNcoMfINXW5p7d7e12Kmpau9tDlnuzrrZSJdUkZoBeaiVkua5B2APLdU1uyCmneZnv0whVNeamAoxQzWNiK3gVkp6HQq5BFhI0yNqvuRDVUZtjx_iveTjxMT4jQh3Eha65j2EvhG0k5anlBh9f7exC2HnmYIa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