-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Try building FFI in CI, including Windows #17
Changes from 12 commits
698c5ef
54162ad
309a054
46aaccb
7a7a288
9c2d602
a60e05f
376a60b
3654e0b
90663b2
3a78ccb
dde1cc8
d5f7380
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,8 @@ mkdir -v -p "$destdir/include/ddprof" "$destdir/lib/pkgconfig" "$destdir/cmake" | |
version=$(awk -F\" '$1 ~ /^version/ { print $2 }' < ddprof-ffi/Cargo.toml) | ||
target="$(rustc -vV | awk '/^host:/ { print $2 }')" | ||
shared_library_suffix=".so" | ||
static_library_suffix=".a" | ||
library_prefix="lib" | ||
remove_rpath=0 | ||
fix_macos_rpath=0 | ||
|
||
|
@@ -32,17 +34,28 @@ case "$target" in | |
# on alpine musl, Rust adds some weird runpath to cdylibs | ||
remove_rpath=1 | ||
;; | ||
|
||
"x86_64-apple-darwin") | ||
expected_native_static_libs=" -framework Security -framework CoreFoundation -liconv -lSystem -lresolv -lc -lm -liconv" | ||
native_static_libs="${expected_native_static_libs}" | ||
shared_library_suffix=".dylib" | ||
# fix usage of library in macos via rpath | ||
fix_macos_rpath=1 | ||
;; | ||
|
||
"x86_64-unknown-linux-gnu"|"aarch64-unknown-linux-gnu") | ||
expected_native_static_libs=" -ldl -lrt -lpthread -lgcc_s -lc -lm -lrt -lpthread -lutil -ldl -lutil" | ||
native_static_libs=" -ldl -lrt -lpthread -lc -lm -lrt -lpthread -lutil -ldl -lutil" | ||
;; | ||
|
||
"x86_64-pc-windows-msvc") | ||
expected_native_static_libs="" # I don't know what to expect | ||
native_static_libs="" # I don't know what to expect | ||
Comment on lines
+52
to
+53
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm. How did we not end up with test failures with these set to blank? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hum good question, maybe because There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the libs There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. but how would you compile using the CMake if you do not specify the list. (sorry new to that) |
||
shared_library_suffix=".dll" | ||
static_library_suffix=".lib" | ||
library_prefix="" | ||
;; | ||
|
||
*) | ||
>&2 echo "Unknown platform '${target}'" | ||
exit 1 | ||
|
@@ -71,28 +84,31 @@ cp -v LICENSE LICENSE-3rdparty.yml NOTICE "$destdir/" | |
|
||
export RUSTFLAGS="${RUSTFLAGS:- -C relocation-model=pic}" | ||
|
||
echo "Building the libddprof_ffi library (may take some time)..." | ||
echo "Building the ddprof_ffi library (may take some time)..." | ||
cargo build --release --target "${target}" | ||
cp -v "target/${target}/release/libddprof_ffi.a" "target/${target}/release/libddprof_ffi${shared_library_suffix}" "$destdir/lib/" | ||
|
||
shared_library_name="${library_prefix}ddprof_ffi${shared_library_suffix}" | ||
static_library_name="${library_prefix}ddprof_ffi${static_library_suffix}" | ||
cp -v "target/${target}/release/$static_library_name" "target/${target}/release/$shared_library_name" "$destdir/lib/" | ||
|
||
if [[ "$remove_rpath" -eq 1 ]]; then | ||
patchelf --remove-rpath "$destdir/lib/libddprof_ffi${shared_library_suffix}" | ||
patchelf --remove-rpath "$destdir/lib/${shared_library_name}" | ||
fi | ||
|
||
if [[ "$fix_macos_rpath" -eq 1 ]]; then | ||
install_name_tool -id @rpath/libddprof_ffi${shared_library_suffix} "$destdir/lib/libddprof_ffi${shared_library_suffix}" | ||
install_name_tool -id @rpath/${shared_library_name} "$destdir/lib/${shared_library_name}" | ||
fi | ||
|
||
# objcopy might not be available on macOS | ||
if command -v objcopy > /dev/null; then | ||
if command -v objcopy > /dev/null && [[ "$target" != "x86_64-pc-windows-msvc" ]]; then | ||
# Remove .llvmbc section which is not useful for clients | ||
objcopy --remove-section .llvmbc "$destdir/lib/libddprof_ffi.a" | ||
objcopy --remove-section .llvmbc "$destdir/lib/${static_library_name}" | ||
|
||
# Ship debug information separate from shared library, so that downstream packages can selectively include it | ||
# https://sourceware.org/gdb/onlinedocs/gdb/Separate-Debug-Files.html | ||
objcopy --only-keep-debug "$destdir/lib/libddprof_ffi${shared_library_suffix}" "$destdir/lib/libddprof_ffi${shared_library_suffix}.debug" | ||
strip -S "$destdir/lib/libddprof_ffi${shared_library_suffix}" | ||
objcopy --add-gnu-debuglink="$destdir/lib/libddprof_ffi${shared_library_suffix}.debug" "$destdir/lib/libddprof_ffi${shared_library_suffix}" | ||
objcopy --only-keep-debug "$destdir/lib/$shared_library_name" "$destdir/lib/$shared_library_name.debug" | ||
strip -S "$destdir/lib/$shared_library_name" | ||
objcopy --add-gnu-debuglink="$destdir/lib/$shared_library_name.debug" "$destdir/lib/$shared_library_name" | ||
fi | ||
|
||
echo "Checking that native-static-libs are as expected for this platform..." | ||
|
@@ -118,7 +134,7 @@ if [ -n "$unexpected_native_libs" ]; then | |
fi | ||
cd - | ||
|
||
echo "Generating the ddprof/ffi.h header..." | ||
echo "Generating the $destdir/ddprof/ffi.h header..." | ||
morrisonlevi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
cbindgen --crate ddprof-ffi --config ddprof-ffi/cbindgen.toml --output "$destdir/include/ddprof/ffi.h" | ||
|
||
# CI doesn't have any clang tooling | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we consider the lock file ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think since we commit
Cargo.lock
anyway that it doesn't matter. If we update a version, then it won't be in the cache and it will pull it.