diff --git a/CMakeLists.txt b/CMakeLists.txt index 1c0218e305..55198f3581 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -87,10 +87,15 @@ option(ZIG_TEST_COVERAGE "Build Zig with test coverage instrumentation" OFF) set(ZIG_TARGET_TRIPLE "native" CACHE STRING "arch-os-abi to output binaries for") set(ZIG_TARGET_MCPU "baseline" CACHE STRING "-mcpu parameter to output binaries for") set(ZIG_EXECUTABLE "" CACHE STRING "(when cross compiling) path to already-built zig binary") -set(ZIG_PREFER_LLVM_CONFIG off CACHE BOOL "(when cross compiling) use llvm-config to find target llvm dependencies if needed") set(ZIG_SINGLE_THREADED off CACHE BOOL "limit the zig compiler to use only 1 thread") set(ZIG_OMIT_STAGE2 off CACHE BOOL "omit the stage2 backend from stage1") +if("${ZIG_TARGET_TRIPLE}" STREQUAL "native") + set(ZIG_USE_LLVM_CONFIG ON CACHE BOOL "use llvm-config to find LLVM libraries") +else() + set(ZIG_USE_LLVM_CONFIG OFF CACHE BOOL "use llvm-config to find LLVM libraries") +endif() + find_package(llvm) find_package(clang) find_package(lld) diff --git a/cmake/Findllvm.cmake b/cmake/Findllvm.cmake index 2ab2c23ad0..bfde645cad 100644 --- a/cmake/Findllvm.cmake +++ b/cmake/Findllvm.cmake @@ -63,7 +63,7 @@ if(ZIG_PREFER_CLANG_CPP_DYLIB) if("${LLVM_CONFIG_VERSION}" VERSION_GREATER 13) message(FATAL_ERROR "expected LLVM 12.x but found ${LLVM_CONFIG_VERSION} using ${LLVM_CONFIG_EXE}") endif() -elseif(("${ZIG_TARGET_TRIPLE}" STREQUAL "native") OR ZIG_PREFER_LLVM_CONFIG) +elseif(ZIG_USE_LLVM_CONFIG) find_program(LLVM_CONFIG_EXE NAMES llvm-config-12 llvm-config-12.0 llvm-config120 llvm-config12 llvm-config PATHS diff --git a/doc/langref.html.in b/doc/langref.html.in index 645c03dcbb..aca09c55fe 100644 --- a/doc/langref.html.in +++ b/doc/langref.html.in @@ -684,7 +684,7 @@ pub fn main() void { {#header_close#} {#header_open|String Literals and Unicode Code Point Literals#}

- String literals are single-item constant {#link|Pointers#} to null-terminated byte arrays. + String literals are constant single-item {#link|Pointers#} to null-terminated byte arrays. The type of string literals encodes both the length, and the fact that they are null-terminated, and thus they can be {#link|coerced|Type Coercion#} to both {#link|Slices#} and {#link|Null-Terminated Pointers|Sentinel-Terminated Pointers#}. @@ -1783,7 +1783,7 @@ comptime { expect(message.len == 5); } -// A string literal is a pointer to an array literal. +// A string literal is a single-item pointer to an array literal. const same_message = "hello"; comptime { @@ -1989,15 +1989,15 @@ test "null terminated array" { {#header_open|Pointers#}

- Zig has two kinds of pointers: + Zig has two kinds of pointers: single-item and many-item.