You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Proposal: standard wrappers for zig cc and zig c++ #8716
There are multiple existing tools which require a direct filename or filepath for C/C++ compiler(s), which causes issues when trying to use Zig's executable+argument (zig + cc) sub-command. People currently work around this by creating bash / batch wrappers which forward the arguments to zig cc or zig c++.
Given the above: Should we consider distributing two standard wrappers with Zig (e.g. zigcc and zigcxx) which would redirect arguments to zig cc and zig c++?
Reacted by Sadiinso, RedbeanW and daniel-heater-imprivata
This would have helped quite a bit while trying to use zig within build scripts with guix. Instead of just zigcc and zigcxx, it would be nice if all commands came with a single word variant.
zig-cc
zig-c++
zig-build
zig-build-exe
zig-ld
zig-ar
and so on
The wrappers might be easy to write but within build scripts you'd either repackage zig to export them or add them to every script it's needed in which quickly becomes error prone.
This would have helped quite a bit while trying to use zig within build scripts with guix. Instead of just zigcc and zigcxx, it would be nice if all commands came with a single word variant.
* `zig-cc`
* `zig-c++`
* `zig-build`
* `zig-build-exe`
* `zig-ld`
* `zig-ar`
* and so on
The wrappers might be easy to write but within build scripts you'd either repackage zig to export them or add them to every script it's needed in which quickly becomes error prone.
@andrewrk might correct me here but I believe the idea is to ultimately drop in a build.zig file and use Zig as a full build system replacement for CMake etc., in which case adding single-word variants for all the commands is moot.
Such wrappers are convenient, however they are a detail of the "glue" code between a Zig distribution and the system it is run on. Such wrappers will need system-specific code. Out of scope for this repository.
There are multiple existing tools which require a direct filename or filepath for C/C++ compiler(s), which causes issues when trying to use Zig's executable+argument (zig + cc) sub-command. People currently work around this by creating bash / batch wrappers which forward the arguments to zig cc or zig c++.
Given the above: Should we consider distributing two standard wrappers with Zig (e.g. zigcc and zigcxx) which would redirect arguments to zig cc and zig c++?
Do you mind sharing your solution using the "some other undocumented cmake flags"?? I am also finding it very difficult using zig cc with CMake.
Although some macOS specific issues occur, the original proposal here is resolved.
Full output for who is interested in:
$ /opt/homebrew/bin/cmake /Users/chenzili/Brittani/kvrocks -DCMAKE_BUILD_TYPE=RelWithDebInfo -G Ninja -DCMAKE_CXX_COMPILER=/Users/chenzili/Brittani/kvrocks/zig-cxx
-- The CXX compiler identification is Clang 15.0.3
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Users/chenzili/Brittani/kvrocks/zig-cxx - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- The C compiler identification is AppleClang 14.0.0.14000029
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Found Python: /opt/homebrew/Frameworks/Python.framework/Versions/3.11/bin/python3.11 (found version "3.11.0") found components: Interpreter
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
-- Could NOT find Unwind (missing: Unwind_LIBRARY)
-- Looking for C++ include unwind.h
-- Looking for C++ include unwind.h - found
-- Looking for _Unwind_Backtrace
-- Looking for _Unwind_Backtrace - found
-- Looking for C++ include dlfcn.h
-- Looking for C++ include dlfcn.h - found
-- Looking for C++ include execinfo.h
-- Looking for C++ include execinfo.h - found
-- Looking for C++ include glob.h
-- Looking for C++ include glob.h - found
-- Looking for C++ include inttypes.h
-- Looking for C++ include inttypes.h - found
-- Looking for C++ include memory.h
-- Looking for C++ include memory.h - found
-- Looking for C++ include pwd.h
-- Looking for C++ include pwd.h - found
-- Looking for C++ include stdint.h
-- Looking for C++ include stdint.h - found
-- Looking for C++ include strings.h
-- Looking for C++ include strings.h - found
-- Looking for C++ include sys/stat.h
-- Looking for C++ include sys/stat.h - found
-- Looking for C++ include sys/syscall.h
-- Looking for C++ include sys/syscall.h - found
-- Looking for C++ include sys/time.h
-- Looking for C++ include sys/time.h - found
-- Looking for C++ include sys/types.h
-- Looking for C++ include sys/types.h - found
-- Looking for C++ include sys/utsname.h
-- Looking for C++ include sys/utsname.h - found
-- Looking for C++ include sys/wait.h
-- Looking for C++ include sys/wait.h - found
-- Looking for C++ include syscall.h
-- Looking for C++ include syscall.h - not found
-- Looking for C++ include syslog.h
-- Looking for C++ include syslog.h - found
-- Looking for C++ include ucontext.h
-- Looking for C++ include ucontext.h - not found
-- Looking for C++ include unistd.h
-- Looking for C++ include unistd.h - found
-- Looking for C++ include ext/hash_map
-- Looking for C++ include ext/hash_map - found
-- Looking for C++ include ext/hash_set
-- Looking for C++ include ext/hash_set - found
-- Looking for C++ include ext/slist
-- Looking for C++ include ext/slist - not found
-- Looking for C++ include tr1/unordered_map
-- Looking for C++ include tr1/unordered_map - not found
-- Looking for C++ include tr1/unordered_set
-- Looking for C++ include tr1/unordered_set - not found
-- Looking for C++ include unordered_map
-- Looking for C++ include unordered_map - found
-- Looking for C++ include unordered_set
-- Looking for C++ include unordered_set - found
-- Looking for C++ include stddef.h
-- Looking for C++ include stddef.h - found
-- Check size of unsigned __int16
-- Check size of unsigned __int16 - failed
-- Check size of u_int16_t
-- Check size of u_int16_t - done
-- Check size of uint16_t
-- Check size of uint16_t - done
-- Looking for dladdr
-- Looking for dladdr - found
-- Looking for fcntl
-- Looking for fcntl - found
-- Looking for pread
-- Looking for pread - found
-- Looking for pwrite
-- Looking for pwrite - found
-- Looking for sigaction
-- Looking for sigaction - found
-- Looking for sigaltstack
-- Looking for sigaltstack - found
-- Performing Test HAVE_NO_DEPRECATED
-- Performing Test HAVE_NO_DEPRECATED - Success
-- Performing Test HAVE_NO_UNNAMED_TYPE_TEMPLATE_ARGS
-- Performing Test HAVE_NO_UNNAMED_TYPE_TEMPLATE_ARGS - Success
-- Looking for pthread_threadid_np
-- Looking for pthread_threadid_np - found
-- Looking for snprintf
-- Looking for snprintf - found
-- Looking for UnDecorateSymbolName in dbghelp
-- Looking for UnDecorateSymbolName in dbghelp - not found
-- Performing Test HAVE___ATTRIBUTE__
-- Performing Test HAVE___ATTRIBUTE__ - Success
-- Performing Test HAVE___ATTRIBUTE__VISIBILITY_DEFAULT
-- Performing Test HAVE___ATTRIBUTE__VISIBILITY_DEFAULT - Success
-- Performing Test HAVE___ATTRIBUTE__VISIBILITY_HIDDEN
-- Performing Test HAVE___ATTRIBUTE__VISIBILITY_HIDDEN - Success
-- Performing Test HAVE___BUILTIN_EXPECT
-- Performing Test HAVE___BUILTIN_EXPECT - Success
-- Performing Test HAVE___SYNC_VAL_COMPARE_AND_SWAP
-- Performing Test HAVE___SYNC_VAL_COMPARE_AND_SWAP - Success
-- Performing Test HAVE_RWLOCK
-- Performing Test HAVE_RWLOCK - Success
-- Performing Test HAVE___DECLSPEC
-- Performing Test HAVE___DECLSPEC - Failed
-- Performing Test STL_NO_NAMESPACE
-- Performing Test STL_NO_NAMESPACE - Failed
-- Performing Test STL_STD_NAMESPACE
-- Performing Test STL_STD_NAMESPACE - Success
-- Performing Test HAVE_USING_OPERATOR
-- Performing Test HAVE_USING_OPERATOR - Success
-- Performing Test HAVE_NAMESPACES
-- Performing Test HAVE_NAMESPACES - Success
-- Performing Test HAVE_GCC_TLS
-- Performing Test HAVE_GCC_TLS - Success
-- Performing Test HAVE_MSVC_TLS
-- Performing Test HAVE_MSVC_TLS - Failed
-- Performing Test HAVE_CXX11_TLS
-- Performing Test HAVE_CXX11_TLS - Success
-- Performing Test HAVE_ALIGNED_STORAGE
-- Performing Test HAVE_ALIGNED_STORAGE - Success
-- Performing Test HAVE_CXX11_ATOMIC
-- Performing Test HAVE_CXX11_ATOMIC - Success
-- Performing Test HAVE_CXX11_CONSTEXPR
-- Performing Test HAVE_CXX11_CONSTEXPR - Success
-- Performing Test HAVE_CXX11_CHRONO
-- Performing Test HAVE_CXX11_CHRONO - Success
-- Performing Test HAVE_CXX11_NULLPTR_T
-- Performing Test HAVE_CXX11_NULLPTR_T - Success
-- Performing Test HAVE_LOCALTIME_R
-- Performing Test HAVE_LOCALTIME_R - Success
-- Performing Test COMPILER_HAS_HIDDEN_VISIBILITY
-- Performing Test COMPILER_HAS_HIDDEN_VISIBILITY - Success
-- Performing Test COMPILER_HAS_HIDDEN_INLINE_VISIBILITY
-- Performing Test COMPILER_HAS_HIDDEN_INLINE_VISIBILITY - Success
-- Performing Test COMPILER_HAS_DEPRECATED_ATTR
-- Performing Test COMPILER_HAS_DEPRECATED_ATTR - Success
-- Looking for byteswap.h
-- Looking for byteswap.h - not found
-- Looking for sys/endian.h
-- Looking for sys/endian.h - not found
-- Looking for sys/mman.h
-- Looking for sys/mman.h - found
-- Looking for sys/resource.h
-- Looking for sys/resource.h - found
-- Looking for sys/uio.h
-- Looking for sys/uio.h - found
-- Looking for windows.h
-- Looking for windows.h - not found
-- Looking for zlibVersion in z
-- Looking for zlibVersion in z - found
-- Looking for lzo1x_1_15_compress in lzo2
-- Looking for lzo1x_1_15_compress in lzo2 - not found
-- Performing Test HAVE_BUILTIN_EXPECT
-- Performing Test HAVE_BUILTIN_EXPECT - Success
-- Performing Test HAVE_BUILTIN_CTZ
-- Performing Test HAVE_BUILTIN_CTZ - Success
-- Looking for mmap
-- Looking for mmap - found
-- Looking for sysconf
-- Looking for sysconf - found
CMake Deprecation Warning at build/_deps/zlib-src/CMakeLists.txt:1 (cmake_minimum_required):
Compatibility with CMake < 2.8.12 will be removed from a future version of
CMake.
Update the VERSION argument value or use a ... suffix to tell
CMake that the project does not need compatibility with older versions.
-- Check size of off64_t
-- Check size of off64_t - failed
-- Looking for fseeko
-- Looking for fseeko - found
-- Looking for unistd.h
-- Looking for unistd.h - found
-- The ASM compiler identification is Clang with GNU-like command-line
-- Found assembler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
-- Found Snappy in /Users/chenzili/Brittani/kvrocks/build/_deps/snappy-src
-- Found zlib in /Users/chenzili/Brittani/kvrocks/build/_deps/zlib-src
-- Found lz4 in /Users/chenzili/Brittani/kvrocks/build/_deps/lz4-src
-- Found zstd in /Users/chenzili/Brittani/kvrocks/build/_deps/zstd-src
-- Performing Test HAVE_OMIT_LEAF_FRAME_POINTER
-- Performing Test HAVE_OMIT_LEAF_FRAME_POINTER - Success
-- Performing Test HAS_ARMV8_CRC
-- Performing Test HAS_ARMV8_CRC - Success
-- HAS_ARMV8_CRC yes
-- Performing Test HAVE_SSE42
-- Performing Test HAVE_SSE42 - Failed
-- Performing Test BUILTIN_ATOMIC
-- Performing Test BUILTIN_ATOMIC - Failed
-- Could NOT find uring (missing: uring_LIBRARIES uring_INCLUDE_DIR)
-- Enabling RTTI in all builds
-- Performing Test HAVE_FALLOCATE
-- Performing Test HAVE_FALLOCATE - Failed
-- Performing Test HAVE_SYNC_FILE_RANGE_WRITE
-- Performing Test HAVE_SYNC_FILE_RANGE_WRITE - Failed
-- Performing Test HAVE_PTHREAD_MUTEX_ADAPTIVE_NP
-- Performing Test HAVE_PTHREAD_MUTEX_ADAPTIVE_NP - Failed
-- Looking for malloc_usable_size
-- Looking for malloc_usable_size - not found
-- Looking for sched_getcpu
-- Looking for sched_getcpu - not found
-- Looking for getauxval
-- Looking for getauxval - not found
-- Looking for F_FULLFSYNC
-- Looking for F_FULLFSYNC - not found
-- ROCKSDB_PLUGINS:
-- ROCKSDB PLUGINS TO BUILD
-- Found Git: /opt/homebrew/bin/git (found version "2.38.1")
-- JNI library is disabled
-- Performing Test check_c_compiler_flag__fdiagnostics_color_always
-- Performing Test check_c_compiler_flag__fdiagnostics_color_always - Success
-- Performing Test check_c_compiler_flag__Wall
-- Performing Test check_c_compiler_flag__Wall - Success
-- Performing Test check_c_compiler_flag__Wextra
-- Performing Test check_c_compiler_flag__Wextra - Success
-- Performing Test check_c_compiler_flag__Wno_unused_parameter
-- Performing Test check_c_compiler_flag__Wno_unused_parameter - Success
-- Performing Test check_c_compiler_flag__Wstrict_aliasing
-- Performing Test check_c_compiler_flag__Wstrict_aliasing - Success
-- Performing Test check_c_compiler_flag__Wstrict_prototypes
-- Performing Test check_c_compiler_flag__Wstrict_prototypes - Success
-- Performing Test check_c_compiler_flag__fno_strict_aliasing
-- Performing Test check_c_compiler_flag__fno_strict_aliasing - Success
-- Performing Test check_c_compiler_flag__Wmissing_prototypes
-- Performing Test check_c_compiler_flag__Wmissing_prototypes - Success
-- Performing Test check_c_compiler_flag__Winit_self
-- Performing Test check_c_compiler_flag__Winit_self - Success
-- Performing Test check_c_compiler_flag__Wmissing_field_initializers
-- Performing Test check_c_compiler_flag__Wmissing_field_initializers - Success
-- Performing Test check_c_compiler_flag__Wdeclaration_after_statement
-- Performing Test check_c_compiler_flag__Wdeclaration_after_statement - Success
-- Performing Test check_c_compiler_flag__Waddress
-- Performing Test check_c_compiler_flag__Waddress - Success
-- Performing Test check_c_compiler_flag__Wnormalized_id
-- Performing Test check_c_compiler_flag__Wnormalized_id - Failed
-- Performing Test check_c_compiler_flag__Woverride_init
-- Performing Test check_c_compiler_flag__Woverride_init - Success
-- Performing Test check_c_compiler_flag__Wlogical_op
-- Performing Test check_c_compiler_flag__Wlogical_op - Failed
-- Performing Test check_c_compiler_flag__Wwrite_strings
-- Performing Test check_c_compiler_flag__Wwrite_strings - Success
-- Performing Test check_c_compiler_flag__Wno_unused_function
-- Performing Test check_c_compiler_flag__Wno_unused_function - Success
-- Performing Test check_c_compiler_flag__Wno_error_deprecated_declarations
-- Performing Test check_c_compiler_flag__Wno_error_deprecated_declarations - Success
-- Performing Test check_c_compiler_flag__Qunused_arguments
-- Performing Test check_c_compiler_flag__Qunused_arguments - Success
-- Looking for GNU_LIBRARY
-- Looking for GNU_LIBRARY - not found
-- Looking for _GNU_SOURCE
-- Looking for _GNU_SOURCE - not found
-- Looking for include file fcntl.h
-- Looking for include file fcntl.h - found
-- Looking for include files fcntl.h, inttypes.h
-- Looking for include files fcntl.h, inttypes.h - found
-- Looking for 3 include files fcntl.h, ..., memory.h
-- Looking for 3 include files fcntl.h, ..., memory.h - found
-- Looking for 4 include files fcntl.h, ..., signal.h
-- Looking for 4 include files fcntl.h, ..., signal.h - found
-- Looking for 5 include files fcntl.h, ..., stdarg.h
-- Looking for 5 include files fcntl.h, ..., stdarg.h - found
-- Looking for 6 include files fcntl.h, ..., stddef.h
-- Looking for 6 include files fcntl.h, ..., stddef.h - found
-- Looking for 7 include files fcntl.h, ..., stdint.h
-- Looking for 7 include files fcntl.h, ..., stdint.h - found
-- Looking for 8 include files fcntl.h, ..., stdlib.h
-- Looking for 8 include files fcntl.h, ..., stdlib.h - found
-- Looking for 9 include files fcntl.h, ..., string.h
-- Looking for 9 include files fcntl.h, ..., string.h - found
-- Looking for 10 include files fcntl.h, ..., errno.h
-- Looking for 10 include files fcntl.h, ..., errno.h - found
-- Looking for 11 include files fcntl.h, ..., unistd.h
-- Looking for 11 include files fcntl.h, ..., unistd.h - found
-- Looking for 12 include files fcntl.h, ..., time.h
-- Looking for 12 include files fcntl.h, ..., time.h - found
-- Looking for 13 include files fcntl.h, ..., sys/types.h
-- Looking for 13 include files fcntl.h, ..., sys/types.h - found
-- Looking for 14 include files fcntl.h, ..., sys/stat.h
-- Looking for 14 include files fcntl.h, ..., sys/stat.h - found
-- Looking for 15 include files fcntl.h, ..., sys/time.h
-- Looking for 15 include files fcntl.h, ..., sys/time.h - found
-- Looking for 16 include files fcntl.h, ..., sys/param.h
-- Looking for 16 include files fcntl.h, ..., sys/param.h - found
-- Looking for 17 include files fcntl.h, ..., netdb.h
-- Looking for 17 include files fcntl.h, ..., netdb.h - found
-- Looking for 18 include files fcntl.h, ..., dlfcn.h
-- Looking for 18 include files fcntl.h, ..., dlfcn.h - found
-- Looking for 19 include files fcntl.h, ..., arpa/inet.h
-- Looking for 19 include files fcntl.h, ..., arpa/inet.h - found
-- Looking for 20 include files fcntl.h, ..., poll.h
-- Looking for 20 include files fcntl.h, ..., poll.h - found
-- Looking for 21 include files fcntl.h, ..., port.h
-- Looking for 21 include files fcntl.h, ..., port.h - not found
-- Looking for 21 include files fcntl.h, ..., sys/socket.h
-- Looking for 21 include files fcntl.h, ..., sys/socket.h - found
-- Looking for 22 include files fcntl.h, ..., sys/random.h
-- Looking for 22 include files fcntl.h, ..., sys/random.h - found
-- Looking for 23 include files fcntl.h, ..., sys/un.h
-- Looking for 23 include files fcntl.h, ..., sys/un.h - found
-- Looking for 24 include files fcntl.h, ..., sys/devpoll.h
-- Looking for 24 include files fcntl.h, ..., sys/devpoll.h - not found
-- Looking for 24 include files fcntl.h, ..., sys/epoll.h
-- Looking for 24 include files fcntl.h, ..., sys/epoll.h - not found
-- Looking for 24 include files fcntl.h, ..., sys/eventfd.h
-- Looking for 24 include files fcntl.h, ..., sys/eventfd.h - not found
-- Looking for 24 include files fcntl.h, ..., sys/event.h
-- Looking for 24 include files fcntl.h, ..., sys/event.h - found
-- Looking for 25 include files fcntl.h, ..., sys/ioctl.h
-- Looking for 25 include files fcntl.h, ..., sys/ioctl.h - found
-- Looking for 26 include files fcntl.h, ..., sys/mman.h
-- Looking for 26 include files fcntl.h, ..., sys/mman.h - found
-- Looking for 27 include files fcntl.h, ..., sys/queue.h
-- Looking for 27 include files fcntl.h, ..., sys/queue.h - found
-- Looking for 28 include files fcntl.h, ..., sys/select.h
-- Looking for 28 include files fcntl.h, ..., sys/select.h - found
-- Looking for 29 include files fcntl.h, ..., sys/sendfile.h
-- Looking for 29 include files fcntl.h, ..., sys/sendfile.h - not found
-- Looking for 29 include files fcntl.h, ..., sys/uio.h
-- Looking for 29 include files fcntl.h, ..., sys/uio.h - found
-- Looking for 30 include files fcntl.h, ..., sys/wait.h
-- Looking for 30 include files fcntl.h, ..., sys/wait.h - found
-- Looking for 31 include files fcntl.h, ..., sys/resource.h
-- Looking for 31 include files fcntl.h, ..., sys/resource.h - found
-- Looking for 32 include files fcntl.h, ..., sys/timerfd.h
-- Looking for 32 include files fcntl.h, ..., sys/timerfd.h - not found
-- Looking for 32 include files fcntl.h, ..., netinet/in.h
-- Looking for 32 include files fcntl.h, ..., netinet/in.h - found
-- Looking for 33 include files fcntl.h, ..., netinet/in6.h
-- Looking for 33 include files fcntl.h, ..., netinet/in6.h - not found
-- Looking for 33 include files fcntl.h, ..., netinet/tcp.h
-- Looking for 33 include files fcntl.h, ..., netinet/tcp.h - found
-- Looking for 34 include files fcntl.h, ..., ifaddrs.h
-- Looking for 34 include files fcntl.h, ..., ifaddrs.h - found
-- Looking for 35 include files fcntl.h, ..., sys/sysctl.h
-- Looking for 35 include files fcntl.h, ..., sys/sysctl.h - found
-- Looking for 36 include files fcntl.h, ..., mach/mach_time.h
-- Looking for 36 include files fcntl.h, ..., mach/mach_time.h - found
-- Looking for 37 include files fcntl.h, ..., mach/mach.h
-- Looking for 37 include files fcntl.h, ..., mach/mach.h - found
-- Looking for getaddrinfo
-- Looking for getaddrinfo - found
-- Looking for getnameinfo
-- Looking for getnameinfo - found
-- Looking for getprotobynumber
-- Looking for getprotobynumber - found
-- Looking for getservbyname
-- Looking for getservbyname - found
-- Looking for gethostbyname
-- Looking for gethostbyname - found
-- Looking for inet_ntop
-- Looking for inet_ntop - found
-- Looking for inet_pton
-- Looking for inet_pton - found
-- Looking for gettimeofday
-- Looking for gettimeofday - found
-- Looking for signal
-- Looking for signal - found
-- Looking for strtoll
-- Looking for strtoll - found
-- Looking for splice
-- Looking for splice - not found
-- Looking for strlcpy
-- Looking for strlcpy - found
-- Looking for strsep
-- Looking for strsep - found
-- Looking for strtok_r
-- Looking for strtok_r - found
-- Looking for vasprintf
-- Looking for vasprintf - found
-- Looking for timerclear
-- Looking for timerclear - found
-- Looking for timercmp
-- Looking for timercmp - found
-- Looking for timerisset
-- Looking for timerisset - found
-- Looking for timeradd
-- Looking for timeradd - found
-- Looking for nanosleep
-- Looking for nanosleep - found
-- Looking for putenv
-- Looking for putenv - found
-- Looking for umask
-- Looking for umask - found
-- Looking for clock_gettime
-- Looking for clock_gettime - found
-- Looking for getifaddrs
-- Looking for getifaddrs - found
-- Looking for select
-- Looking for select - found
-- Looking for epoll_create
-- Looking for epoll_create - not found
-- Looking for epoll_create1
-- Looking for epoll_create1 - not found
-- Looking for epoll_ctl
-- Looking for epoll_ctl - not found
-- Looking for eventfd
-- Looking for eventfd - not found
-- Looking for poll
-- Looking for poll - found
-- Looking for port_create
-- Looking for port_create - not found
-- Looking for kqueue
-- Looking for kqueue - found
-- Looking for fcntl
-- Looking for fcntl - found
-- Looking for mmap
-- Looking for mmap - found
-- Looking for pipe
-- Looking for pipe - found
-- Looking for pipe2
-- Looking for pipe2 - not found
-- Looking for sendfile
-- Looking for sendfile - found
-- Looking for sigaction
-- Looking for sigaction - found
-- Looking for strsignal
-- Looking for strsignal - found
-- Looking for sysctl
-- Looking for sysctl - found
-- Looking for accept4
-- Looking for accept4 - not found
-- Looking for arc4random
-- Looking for arc4random - found
-- Looking for arc4random_buf
-- Looking for arc4random_buf - found
-- Looking for arc4random_addrandom
-- Looking for arc4random_addrandom - found
-- Looking for getrandom
-- Looking for getrandom - not found
-- Looking for getegid
-- Looking for getegid - found
-- Looking for geteuid
-- Looking for geteuid - found
-- Looking for issetugid
-- Looking for issetugid - found
-- Looking for usleep
-- Looking for usleep - found
-- Looking for timerfd_create
-- Looking for timerfd_create - not found
-- Looking for setenv
-- Looking for setenv - found
-- Looking for unsetenv
-- Looking for unsetenv - found
-- Looking for setrlimit
-- Looking for setrlimit - found
-- Looking for gethostbyname_r
-- Looking for gethostbyname_r - not found
-- Looking for mach_absolute_time
-- Looking for mach_absolute_time - found
-- Check size of struct sockaddr_un
-- Check size of struct sockaddr_un - done
-- Check size of uint8_t
-- Check size of uint8_t - done
-- Check size of uint16_t
-- Check size of uint16_t - done
-- Check size of uint32_t
-- Check size of uint32_t - done
-- Check size of uint64_t
-- Check size of uint64_t - done
-- Check size of short
-- Check size of short - done
-- Check size of int
-- Check size of int - done
-- Check size of unsigned
-- Check size of unsigned - done
-- Check size of unsigned int
-- Check size of unsigned int - done
-- Check size of long
-- Check size of long - done
-- Check size of long long
-- Check size of long long - done
-- Performing Test HAVE_INLINE
-- Performing Test HAVE_INLINE - Success
-- Looking for func
-- Looking for func - found
-- Looking for FUNCTION
-- Looking for FUNCTION - found
-- Looking for TAILQ_FOREACH
-- Looking for TAILQ_FOREACH - found
-- Performing Test EVENT__HAVE_DECL_CTL_KERN
-- Performing Test EVENT__HAVE_DECL_CTL_KERN - Success
-- Looking for CTL_KERN - found
-- Performing Test EVENT__HAVE_DECL_KERN_ARND
-- Performing Test EVENT__HAVE_DECL_KERN_ARND - Failed
-- Looking for KERN_ARND - not found
-- Looking for F_SETFD
-- Looking for F_SETFD - found
-- Check size of fd_mask
-- Check size of fd_mask - done
-- Check size of size_t
-- Check size of size_t - done
-- Check size of off_t
-- Check size of off_t - done
-- Check size of ssize_t
-- Check size of ssize_t - done
-- Check size of SSIZE_T
-- Check size of SSIZE_T - failed
-- Check size of socklen_t
-- Check size of socklen_t - done
-- Check size of pid_t
-- Check size of pid_t - done
-- Check size of pthread_t
-- Check size of pthread_t - done
-- Check size of uintptr_t
-- Check size of uintptr_t - done
-- Check size of void *
-- Check size of void * - done
-- Check size of time_t
-- Check size of time_t - done
CMake Warning at build/_deps/libevent-src/CMakeLists.txt:663 (message):
Cannot check if kqueue works with pipes when crosscompiling, use
EVENT__FORCE_KQUEUE_CHECK to be sure (this requires manually running a test
program on the cross compilation target)
-- Check size of struct addrinfo
-- Check size of struct addrinfo - done
-- Check size of struct in6_addr
-- Check size of struct in6_addr - done
-- Performing Test EVENT__HAVE_STRUCT_IN6_ADDR_S6_ADDR16
-- Performing Test EVENT__HAVE_STRUCT_IN6_ADDR_S6_ADDR16 - Failed
-- Performing Test EVENT__HAVE_STRUCT_IN6_ADDR_S6_ADDR32
-- Performing Test EVENT__HAVE_STRUCT_IN6_ADDR_S6_ADDR32 - Failed
-- Check size of sa_family_t
-- Check size of sa_family_t - done
-- Check size of struct sockaddr_in6
-- Check size of struct sockaddr_in6 - done
-- Performing Test EVENT__HAVE_STRUCT_SOCKADDR_IN6_SIN6_LEN
-- Performing Test EVENT__HAVE_STRUCT_SOCKADDR_IN6_SIN6_LEN - Success
-- Performing Test EVENT__HAVE_STRUCT_SOCKADDR_IN_SIN_LEN
-- Performing Test EVENT__HAVE_STRUCT_SOCKADDR_IN_SIN_LEN - Failed
-- Check size of struct sockaddr_storage
-- Check size of struct sockaddr_storage - done
-- Performing Test EVENT__HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY
-- Performing Test EVENT__HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY - Success
-- Performing Test EVENT__HAVE_STRUCT_SOCKADDR_STORAGE___SS_FAMILY
-- Performing Test EVENT__HAVE_STRUCT_SOCKADDR_STORAGE___SS_FAMILY - Failed
-- Check size of struct linger
-- Check size of struct linger - done
--
-- ---( Libevent 2.1.12-stable )---
--
-- Available event backends:
-- CMAKE_BINARY_DIR: /Users/chenzili/Brittani/kvrocks/build
-- CMAKE_CURRENT_BINARY_DIR: /Users/chenzili/Brittani/kvrocks/build/_deps/libevent-build
-- CMAKE_SOURCE_DIR: /Users/chenzili/Brittani/kvrocks
-- CMAKE_CURRENT_SOURCE_DIR: /Users/chenzili/Brittani/kvrocks/build/_deps/libevent-src
-- PROJECT_BINARY_DIR: /Users/chenzili/Brittani/kvrocks/build/_deps/libevent-build
-- PROJECT_SOURCE_DIR: /Users/chenzili/Brittani/kvrocks/build/_deps/libevent-src
-- CMAKE_MODULE_PATH: /Users/chenzili/Brittani/kvrocks/build/_deps/libevent-src/cmake/
-- CMAKE_COMMAND: /opt/homebrew/Cellar/cmake/3.25.1/bin/cmake
-- CMAKE_ROOT: /opt/homebrew/Cellar/cmake/3.25.1/share/cmake
-- CMAKE_SYSTEM: Darwin-21.6.0
-- CMAKE_SYSTEM_NAME: Darwin
-- CMAKE_SYSTEM_VERSION: 21.6.0
-- CMAKE_SYSTEM_PROCESSOR: arm64
-- CMAKE_SKIP_RPATH: NO
-- CMAKE_VERBOSE_MAKEFILE: FALSE
-- CMAKE_C_FLAGS: -fdiagnostics-color=always -Wall -Wextra -Wno-unused-parameter -Wstrict-aliasing -Wstrict-prototypes -fno-strict-aliasing -Wmissing-prototypes -Winit-self -Wmissing-field-initializers -Wdeclaration-after-statement -Waddress -Woverride-init -Wwrite-strings -Wno-unused-function -Wno-error=deprecated-declarations -Qunused-arguments
-- CMAKE_BUILD_TYPE: RelWithDebInfo
-- CMAKE_C_COMPILER: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc (id AppleClang, clang 1, GNUC 1)
-- CMAKE_AR: /usr/bin/ar
-- CMAKE_RANLIB: /usr/bin/ranlib
--
-- Module support is disabled.
-- Version: 9.1.0
-- Build type: RelWithDebInfo
-- CXX_STANDARD: 17
-- Performing Test has_std_17_flag
-- Performing Test has_std_17_flag - Success
-- Performing Test has_std_1z_flag
-- Performing Test has_std_1z_flag - Success
-- Required features: cxx_variadic_templates
-- Performing Test HAS_NULLPTR_WARNING
-- Performing Test HAS_NULLPTR_WARNING - Success
CMake Warning at CMakeLists.txt:202 (message):
IPO is not supported: Change Dir:
/Users/chenzili/Brittani/kvrocks/build/CMakeFiles/_CMakeLTOTest-CXX/bin
Run Build Command(s):/opt/homebrew/bin/ninja && [1/4] Building CXX object
CMakeFiles/foo.dir/foo.cpp.o
error: LTO is not yet supported with the Mach-O object format. More
details: #8680
ninja: build stopped: subcommand failed.
-- Configuring done
CMake Warning (dev):
Policy CMP0042 is not set: MACOSX_RPATH is enabled by default. Run "cmake
--help-policy CMP0042" for policy details. Use the cmake_policy command to
set the policy and suppress this warning.
MACOSX_RPATH is not specified for the following targets:
zlib
This warning is for project developers. Use -Wno-dev to suppress it.
-- Generating done
-- Build files have been written to: /Users/chenzili/Brittani/kvrocks/build
$ /opt/homebrew/bin/cmake --build . -t kvrocks kvrocks2redis
[1/405] cd /Users/chenzili/Brittani/kv...IS_STATIC=\ -DLUA_USE_MKSTEMP liblua.a
make: `liblua.a' is up to date.
[2/405] Building CXX object _deps/snap...iles/snappy.dir/snappy-sinksource.cc.o
zig: warning: overriding '-mmacosx-version-min=12.5' option with '-target aarch64-unknown-macosx12.6.0-unknown' [-Woverriding-t-option]
[7/405] cd /Users/chenzili/Brittani/kv...fault.xctoolchain/usr/bin/cc libzstd.a
FAILED: CMakeFiles/make_zstd _deps/zstd-src/lib/libzstd.a /Users/chenzili/Brittani/kvrocks/build/CMakeFiles/make_zstd /Users/chenzili/Brittani/kvrocks/build/_deps/zstd-src/lib/libzstd.a
cd /Users/chenzili/Brittani/kvrocks/build/_deps/zstd-src/lib && make CC=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc libzstd.a
CC obj/conf_62f2cfcb3e433a52a45c7de095edd7a6/static/debug.o
CC obj/conf_62f2cfcb3e433a52a45c7de095edd7a6/static/entropy_common.o
In file included from .//common/entropy_common.c:18:
In file included from .//common/mem.h:24:
.//common/zstd_deps.h:29:10: fatal error: 'string.h' file not found
#include <string.h>
^~~~~~~~~~
1 error generated.
make[1]: *** [obj/conf_62f2cfcb3e433a52a45c7de095edd7a6/static/entropy_common.o] Error 1
make: *** [libzstd.a] Error 2
[9/405] Building CXX object _deps/snap...ld/CMakeFiles/snappy.dir/snappy-c.cc.o
zig: warning: overriding '-mmacosx-version-min=12.5' option with '-target aarch64-unknown-macosx12.6.0-unknown' [-Woverriding-t-option]
[10/405] Building CXX object _deps/sna.../snappy.dir/snappy-stubs-internal.cc.o
zig: warning: overriding '-mmacosx-version-min=12.5' option with '-target aarch64-unknown-macosx12.6.0-unknown' [-Woverriding-t-option]
[11/405] Building CXX object _deps/glo...eFiles/glogbase.dir/src/symbolize.cc.o
zig: warning: overriding '-mmacosx-version-min=12.5' option with '-target aarch64-unknown-macosx12.6.0-unknown' [-Woverriding-t-option]
[12/405] Building CXX object _deps/glo...iles/glogbase.dir/src/raw_logging.cc.o
zig: warning: overriding '-mmacosx-version-min=12.5' option with '-target aarch64-unknown-macosx12.6.0-unknown' [-Woverriding-t-option]
[13/405] Building CXX object _deps/glo...eFiles/glogbase.dir/src/utilities.cc.o
zig: warning: overriding '-mmacosx-version-min=12.5' option with '-target aarch64-unknown-macosx12.6.0-unknown' [-Woverriding-t-option]
[14/405] Building CXX object _deps/glo...es/glogbase.dir/src/signalhandler.cc.o
zig: warning: overriding '-mmacosx-version-min=12.5' option with '-target aarch64-unknown-macosx12.6.0-unknown' [-Woverriding-t-option]
[15/405] Building CXX object _deps/glo...Files/glogbase.dir/src/vlog_is_on.cc.o
zig: warning: overriding '-mmacosx-version-min=12.5' option with '-target aarch64-unknown-macosx12.6.0-unknown' [-Woverriding-t-option]
[16/405] Building CXX object _deps/glo...keFiles/glogbase.dir/src/demangle.cc.o
zig: warning: overriding '-mmacosx-version-min=12.5' option with '-target aarch64-unknown-macosx12.6.0-unknown' [-Woverriding-t-option]
[17/405] Building CXX object _deps/sna...uild/CMakeFiles/snappy.dir/snappy.cc.o
zig: warning: overriding '-mmacosx-version-min=12.5' option with '-target aarch64-unknown-macosx12.6.0-unknown' [-Woverriding-t-option]
[18/405] Building CXX object _deps/glo...akeFiles/glogbase.dir/src/logging.cc.o
zig: warning: overriding '-mmacosx-version-min=12.5' option with '-target aarch64-unknown-macosx12.6.0-unknown' [-Woverriding-t-option]
ninja: build stopped: subcommand failed.
Traceback (most recent call last):
File "/Users/chenzili/Brittani/kvrocks/./x.py", line 446, in
args.func(**arg_dict)
File "/Users/chenzili/Brittani/kvrocks/./x.py", line 136, in build
run(cmake, *options, verbose=True, cwd=dir)
File "/Users/chenzili/Brittani/kvrocks/./x.py", line 68, in run
raise RuntimeError(err)
RuntimeError:
failed to run: ('/opt/homebrew/bin/cmake', '--build', '.', '-t', 'kvrocks', 'kvrocks2redis')
exit with code: 1
The answer by @tisonkun breaks when an argument has a space in it. For example, when you build clang, you have a define like -DCLANG_VENDOR="\"CompanyName \"" as set by clang/lib/Basic/CMakeLists.txt:
This gets broken due to some problem with passing the args:
./zig-cxx -DFOO="\"Hi \"" a.cpp
In file included from <built-in>:490:
<command line>:8:13: warning: missing terminating '"' character [-Winvalid-pp-token]
#define FOO "Hi
^
1 warning generated.
LLD Link... ld.lld: error: cannot open ": No such file or directory
Notes from further experimentation: -DCMAKE_C_COMPILER=zig;cc sometimes didn't work for me but that probably was just caused by my CMakeCache being somehow polluted. Therefore the wrapper isn't needed. For example, it is used in zig-bootstrap. What is non-obvious is that -DCMAKE_SYSTEM_NAME="$TARGET_OS_CMAKE" is actually important to avoid some auto-detection magic.
So the problem is this: sometimes the zig tool is called with other parameters before the cc or c++ option.
Therefore to solve this problem I suggest to support the most straightforward solution: support links like zig-cc and zig-cc (plus the others). That's is the solution used by the very good Busybox tool. So if you do ln -s zig zig-cc then calling to zig-cc will be the same as calling to zig cc.
sometimes the zig tool is called with other parameters before the cc or c++ option.
Under what circumstances does this happen?
Running CMake to try to compile Canonical Multipass with ZIG CC.
The CMake process will end without errors starting it with: cmake -DCMAKE_C_COMPILER="zig;cc;-static" -DCMAKE_CXX_COMPILER="zig;c++;-static" ../
But when compiling with make, at some point the compiler called is zig -std=c++17 c++, instead of zig c++ -std=c++17.
Are you sure that wasn't the sort of auto-detection that I mentioned you can get around with CMAKE_SYSTEM_NAME? Commenting a diff on an issue and tagging a maintainer is the same as opening a (maybe draft) PR except less convenient
I've created a draft patch that solves the problem from the root: #22211
The solution is quite simple: if you create a symlink (or rename) the binary with the name "zig-cc" then calling to it will be the same as "zig cc". Therefore any other paramters will be parsed after the "cc". So that's a definitive solution.
The PR is a draft because I need the help from @andrewrk to clean the code, add the resting cases (now only for "cc" and "c++"), and add support for Windows (perhaps adding "zig-cc.exe" checks).
Activity
jedisct1 commentedon May 8, 2021
Yes. This is an issue for
autotools-based code as well, and I also had to write wrappers in order to work around it.Such wrappers are one-liners, though (
exec zig cc "$@"), so maybe documenting this would be enough?tauoverpi commentedon May 9, 2021
This would have helped quite a bit while trying to use zig within build scripts with guix. Instead of just
zigccandzigcxx, it would be nice if all commands came with a single word variant.zig-cczig-c++zig-buildzig-build-exezig-ldzig-arThe wrappers might be easy to write but within build scripts you'd either repackage zig to export them or add them to every script it's needed in which quickly becomes error prone.
kubkon commentedon May 9, 2021
@andrewrk might correct me here but I believe the idea is to ultimately drop in a
build.zigfile and use Zig as a full build system replacement for CMake etc., in which case adding single-word variants for all the commands is moot.jedisct1 commentedon May 9, 2021
Such wrappers remain useful to compile unmodified, existing code.
The ability to effortlessly cross-compile existing C/C++ code is a strong selling point.
Now, should these wrappers be part of the Zig distribution? Maybe not.
They can reside in a dedicated repository, that the documentation can point to.
andrewrk commentedon May 12, 2021
Such wrappers are convenient, however they are a detail of the "glue" code between a Zig distribution and the system it is run on. Such wrappers will need system-specific code. Out of scope for this repository.
mcfriend99 commentedon Oct 12, 2021
Do you mind sharing your solution using the "some other undocumented cmake flags"?? I am also finding it very difficult using
zig ccwith CMake.zhaozg commentedon Oct 12, 2021
Not easy, but not so difficult. look here: https://github.com/zhaozg/luajit-cmake/blob/master/Utils/zig.toolchain.cmake
tisonkun commentedon Dec 16, 2022
FWIW I write a handy script that can work:
zig-cczig-cxxFor Kvrocks project, I run:
Although some macOS specific issues occur, the original proposal here is resolved.
Full output for who is interested in:
mulle-nat commentedon Apr 17, 2023
Since I just ran into this: you can set
-DCMAKE_C_COMPILER="zig;cc"and it will work.multivac61 commentedon Jan 9, 2024
Won't work on macOS. Fortunately @tisonkun answer above does.
widlarizer commentedon Jan 18, 2024
The answer by @tisonkun breaks when an argument has a space in it. For example, when you build clang, you have a define like
-DCLANG_VENDOR="\"CompanyName \""as set byclang/lib/Basic/CMakeLists.txt:This gets broken due to some problem with passing the args:
rootbeer commentedon Jan 18, 2024
If you add quotes around the
$@in the script bash will "do the right thing" and preserve quoting/whitespace around the arguments it passes along:widlarizer commentedon Jan 18, 2024
Notes from further experimentation:
-DCMAKE_C_COMPILER=zig;ccsometimes didn't work for me but that probably was just caused by my CMakeCache being somehow polluted. Therefore the wrapper isn't needed. For example, it is used in zig-bootstrap. What is non-obvious is that-DCMAKE_SYSTEM_NAME="$TARGET_OS_CMAKE"is actually important to avoid some auto-detection magic.lars18th commentedon Nov 20, 2024
Hi @andrewrk (and others),
I know the reasons to maintain the zig binary clean.
And I know (and I use it) that with CMake we can use (i.e.):
cmake -DCMAKE_C_COMPILER="zig;cc;-static" -DCMAKE_CXX_COMPILER="zig;c++;-static" ../But, today I found this error:
So the problem is this: sometimes the
zigtool is called with other parameters before theccorc++option.Therefore to solve this problem I suggest to support the most straightforward solution: support links like
zig-ccandzig-cc(plus the others). That's is the solution used by the very good Busybox tool. So if you doln -s zig zig-ccthen calling tozig-ccwill be the same as calling tozig cc.Please, comment.
widlarizer commentedon Nov 20, 2024
Under what circumstances does this happen?
lars18th commentedon Nov 20, 2024
Running CMake to try to compile Canonical Multipass with ZIG CC.
The CMake process will end without errors starting it with:
cmake -DCMAKE_C_COMPILER="zig;cc;-static" -DCMAKE_CXX_COMPILER="zig;c++;-static" ../But when compiling with
make, at some point the compiler called iszig -std=c++17 c++, instead ofzig c++ -std=c++17.jedisct1 commentedon Nov 20, 2024
This is exactly the issue wrappers would solve.
lars18th commentedon Nov 20, 2024
Hi to all,
I'm experimenting with something like this:
With this if you call to
zig-ccthen it will be equivalent to call tozig cc. And you only need to creat the symlinkln -s zig zig-cc.lars18th commentedon Nov 20, 2024
Hi @andrewrk ,
Please, could you check this patch?
If you agree with this approach, then I'll prepare a PR.
You agree? 😉
NOTE: This patch doesn't work!
widlarizer commentedon Nov 21, 2024
Are you sure that wasn't the sort of auto-detection that I mentioned you can get around with
CMAKE_SYSTEM_NAME? Commenting a diff on an issue and tagging a maintainer is the same as opening a (maybe draft) PR except less convenientlars18th commentedon Nov 21, 2024
Hi @widlarizer ,
I'll need to check it. However, I feel it will wont work because this VAR is not created/used for this pourpose.
Perhaps. But I want to know the opinion from @andrewrk before writing a complete patch (this one is only a functional example).
widlarizer commentedon Nov 21, 2024
I believe that is what draft PRs are exactly for
lars18th commentedon Dec 12, 2024
Hi to all!
I've created a draft patch that solves the problem from the root: #22211
The solution is quite simple: if you create a symlink (or rename) the binary with the name "zig-cc" then calling to it will be the same as "zig cc". Therefore any other paramters will be parsed after the "cc". So that's a definitive solution.
The PR is a draft because I need the help from @andrewrk to clean the code, add the resting cases (now only for "cc" and "c++"), and add support for Windows (perhaps adding "zig-cc.exe" checks).
What you think?
lars18th commentedon Dec 12, 2024
Hi @andrewrk ,
Please can you explain why it is rejected?
My patch does not change anything from the standard behaviour.
nektro commentedon Dec 12, 2024
#8716 (comment)