1+ if (OS_FREEBSD)
2+ # Right nix/libc requires fspacectl and it had been added only since FreeBSD14.
3+ # And since sysroot has older libraries you will got undefined reference for clickhouse binary.
4+ #
5+ # But likely everything should work without this syscall, however it is not
6+ # possible right now to gently override libraries versions for dependencies,
7+ # and forking rust modules is a little bit too much for this thing.
8+ #
9+ # You can take a look at the details in the following issue [1].
10+ #
11+ # [1]: https://github.com/rust-lang/cargo/issues/5640
12+ #
13+ # Update 2024-04: Now prql also requires getrandom() via std::sys::pal::unix::rand::imp::getrandom_fill_bytes
14+ message (STATUS "Rust build is disabled for FreeBSD because we use old sysroot files" )
15+ return ()
16+ endif ()
17+
18+
119# NOTE: should be macro to export RUST_CXXFLAGS/RUST_CFLAGS for subfolders
220macro (configure_rustc)
321 # NOTE: this can also be done by overriding rustc, but it not trivial with rustup.
@@ -52,66 +70,19 @@ macro(configure_rustc)
5270 message (STATUS "RUSTFLAGS: ${RUSTFLAGS} " )
5371 message (STATUS "RUST_CARGO_BUILD_STD: ${RUST_CARGO_BUILD_STD} " )
5472
55- # NOTE: requires RW access for the source dir
56- configure_file ("${CMAKE_CURRENT_SOURCE_DIR} /.cargo/config.toml.in" "${CMAKE_CURRENT_SOURCE_DIR} /.cargo/config.toml" @ONLY)
73+ set (RUST_VENDOR_DIR "${CMAKE_CURRENT_SOURCE_DIR} /../contrib/rust_vendor" )
5774endmacro ()
5875configure_rustc()
5976
60- function (clickhouse_import_crate)
61- # This is a workaround for Corrosion case sensitive build type matching in
62- # _generator_add_cargo_targets(), that leads to different paths in
63- # IMPORTED_LOCATION and real path of the library.
64- #
65- # It uses CMAKE_CONFIGURATION_TYPES and $<CONFIG>, so here we preserve the
66- # case of ${CMAKE_BUILD_TYPE} in ${CMAKE_CONFIGURATION_TYPES}.
67- if ("${CMAKE_BUILD_TYPE_UC} " STREQUAL "DEBUG" )
68- set (CMAKE_CONFIGURATION_TYPES "${CMAKE_BUILD_TYPE} ;release" )
69- else ()
70- set (CMAKE_CONFIGURATION_TYPES "${CMAKE_BUILD_TYPE} ;debug" )
71- endif ()
72-
73- if (CMAKE_BUILD_TYPE_UC STREQUAL "DEBUG" )
74- set (profile "" )
75- else ()
76- if (ENABLE_THINLTO)
77- set (profile "release-thinlto" )
78- else ()
79- set (profile "release" )
80- endif ()
81- endif ()
82-
83- # Note, here --offline is not used, since on CI vendor archive is used, and
84- # passing --offline here will be inconvenient for local development.
85- corrosion_import_crate(NO_STD ${ARGN} PROFILE ${profile} )
86- endfunction ()
87-
8877# Add crate from the build directory.
89- #
90- # Our crates has configuration files:
91- # - config for cargo (see config.toml.in)
92- # - and possibly config for build (build.rs.in)
93- #
94- # And to avoid overlaps different builds for one source directory, crate will
78+ # To avoid overlaps different builds for one source directory, crate will
9579# be copied from source directory to the binary directory.
96- file (COPY ".cargo" DESTINATION "${CMAKE_CURRENT_BINARY_DIR} " )
9780function (add_rust_subdirectory src)
9881 set (dst "${CMAKE_CURRENT_BINARY_DIR} /${src} " )
9982 message (STATUS "Copy ${src} to ${dst} " )
10083 file (COPY "${src} " DESTINATION "${CMAKE_CURRENT_BINARY_DIR} "
10184 PATTERN target EXCLUDE )
10285
103- # Check is Rust available or not.
104- #
105- # `cargo update --dry-run` will not update anything, but will check the internet connectivity.
106- execute_process (COMMAND ${Rust_CARGO_CACHED} update --dry-run
107- WORKING_DIRECTORY "${dst} "
108- RESULT_VARIABLE CARGO_UPDATE_RESULT
109- OUTPUT_VARIABLE CARGO_UPDATE_STDOUT
110- ERROR_VARIABLE CARGO_UPDATE_STDERR)
111- if (CARGO_UPDATE_RESULT)
112- message (FATAL_ERROR "Rust (${Rust_CARGO_CACHED} ) support is not available (likely there is no internet connectivity):\n ${CARGO_UPDATE_STDERR} \n You can disable Rust support with -DENABLE_RUST=OFF" )
113- endif ()
114-
11586 add_subdirectory ("${dst} " "${dst} " )
11687
11788 # cmake -E copy* do now know how to exclude files
@@ -126,5 +97,4 @@ function(add_rust_subdirectory src)
12697 VERBATIM )
12798endfunction ()
12899
129- add_rust_subdirectory (skim)
130- add_rust_subdirectory (prql)
100+ add_rust_subdirectory (workspace)
0 commit comments