Skip to content

Commit

Permalink
Merge pull request #9429 from habitat-sh/broke
Browse files Browse the repository at this point in the history
fix broken stdlib linking
  • Loading branch information
mwrock authored Oct 17, 2024
2 parents d64dc5d + b2b15cd commit a9eb966
Show file tree
Hide file tree
Showing 5 changed files with 180 additions and 3 deletions.
2 changes: 1 addition & 1 deletion components/launcher/habitat/plan.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pkg_origin=core
pkg_maintainer="The Habitat Maintainers <[email protected]>"
pkg_license=('Apache-2.0')
pkg_deps=(core/glibc
core/gcc-libs)
core/gcc-base)
pkg_build_deps=(core/coreutils
core/rust/"$(tail -n 1 "$SRC_PATH/../../rust-toolchain" | cut -d'"' -f 2)"
core/gcc
Expand Down
69 changes: 69 additions & 0 deletions components/launcher/habitat/x86_64-linux-kernel2/plan.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# shellcheck disable=2154
pkg_name=hab-launcher
pkg_origin=core
pkg_maintainer="The Habitat Maintainers <[email protected]>"
pkg_license=('Apache-2.0')
pkg_deps=(core/glibc
core/gcc-libs)
pkg_build_deps=(core/coreutils
core/rust/"$(tail -n 1 "$SRC_PATH/../../rust-toolchain" | cut -d'"' -f 2)"
core/gcc
core/git
core/protobuf)
pkg_bin_dirs=(bin)
bin="hab-launch"

# Use the number of commits from the start of this repository
# to the current HEAD as the version for our pkg_version
pkg_version() {
git config --global --add safe.directory /src
git rev-list "$(git rev-parse HEAD)" --count
}

do_before() {
update_pkg_version
}

# shellcheck disable=2155
do_prepare() {
export cargo_build_mode="${cargo_build_mode:---release}"
# Can be either `--release` or `--debug` to determine cargo build strategy
build_line "Building artifacts with \`${cargo_build_mode#--}' mode"

export rustc_target="x86_64-unknown-linux-gnu"
build_line "Setting rustc_target=$rustc_target"

# Used by Cargo to use a pristine, isolated directory for all compilation
export CARGO_TARGET_DIR="$HAB_CACHE_SRC_PATH/$pkg_dirname"
build_line "Setting CARGO_TARGET_DIR=$CARGO_TARGET_DIR"

export PLAN_VERSION="${pkg_version}"
build_line "Setting PLAN_VERSION=$PLAN_VERSION"

# Prost (our Rust protobuf library) embeds a `protoc` binary, but
# it's dynamically linked, which means it won't work in a
# Studio. Prost does allow us to override that, though, so we can
# just use our Habitat package by setting these two environment
# variables.
export PROTOC="$(pkg_path_for protobuf)/bin/protoc"
export PROTOC_INCLUDE="$(pkg_path_for protobuf)/include"

# Used to set the active package target for the binaries at build time
export PLAN_PACKAGE_TARGET="$pkg_target"
build_line "Setting PLAN_PACKAGE_TARGET=$PLAN_PACKAGE_TARGET"
}

do_build() {
pushd "$SRC_PATH" > /dev/null || exit
cargo build "${cargo_build_mode#--debug}" --target="$rustc_target" --verbose
popd > /dev/null || exit
}

do_install() {
install -v -D "$CARGO_TARGET_DIR"/"$rustc_target"/"${cargo_build_mode#--}"/$bin \
"$pkg_prefix"/bin/$bin
}

do_strip() {
strip --strip-debug "$pkg_prefix"/bin/$bin
}
2 changes: 1 addition & 1 deletion components/sup/habitat/plan.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pkg_maintainer="The Habitat Maintainers <[email protected]>"
pkg_license=('Apache-2.0')
pkg_deps=(core/busybox-static
core/glibc
core/gcc-libs
core/gcc-base
core/zeromq)
pkg_build_deps=(core/coreutils
core/cacerts
Expand Down
108 changes: 108 additions & 0 deletions components/sup/habitat/x86_64-linux-kernel2/plan.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
# shellcheck disable=2034,2154
pkg_name=hab-sup
_pkg_distname=$pkg_name
pkg_origin=core
pkg_maintainer="The Habitat Maintainers <[email protected]>"
pkg_license=('Apache-2.0')
pkg_deps=(core/busybox-static
core/glibc
core/gcc-libs
core/zeromq)
pkg_build_deps=(core/coreutils
core/cacerts
core/make
core/perl # Needed for vendored openssl-sys
core/rust/"$(tail -n 1 "$SRC_PATH/../../rust-toolchain" | cut -d'"' -f 2)"
core/gcc
core/raml2html
core/protobuf)
pkg_bin_dirs=(bin)

bin=$_pkg_distname

_common_prepare() {
do_default_prepare

# Can be either `--release` or `--debug` to determine cargo build strategy
build_type="--release"
build_line "Building artifacts with \`${build_type#--}' mode"

# Used by the `build.rs` program to set the version of the binaries
export PLAN_VERSION="${pkg_version}/${pkg_release}"
build_line "Setting PLAN_VERSION=$PLAN_VERSION"

# Used to set the active package target for the binaries at build time
export PLAN_PACKAGE_TARGET="$pkg_target"
build_line "Setting PLAN_PACKAGE_TARGET=$PLAN_PACKAGE_TARGET"

if [ -z "$HAB_CARGO_TARGET_DIR" ]; then
# Used by Cargo to use a pristine, isolated directory for all compilation
export CARGO_TARGET_DIR="$HAB_CACHE_SRC_PATH/$pkg_dirname"
else
export CARGO_TARGET_DIR="$HAB_CARGO_TARGET_DIR"
fi
build_line "Setting CARGO_TARGET_DIR=$CARGO_TARGET_DIR"
}

pkg_version() {
cat "$SRC_PATH/../../VERSION"
}

do_before() {
do_default_before
update_pkg_version
}

# shellcheck disable=2155
do_prepare() {
_common_prepare

export rustc_target="x86_64-unknown-linux-gnu"
build_line "Setting rustc_target=$rustc_target"

export LIBZMQ_PREFIX=$(pkg_path_for zeromq)

# TODO (CM, FN): This is not needed to build the supervisor,
# strictly speaking, but is instead a work-around for how we are
# currently building packages in Travis; we hypothesize that the
# build.rs program for habitat_http_client, built during a static
# hab package build, is being inadvertently used here. Without gcc
# libs on the LD_LIBRARY_PATH, the program can't find
# libgcc_s.so.1. This is merely a bandaid until we can overhaul our
# CI pipeline properly.
#
# Used to find libgcc_s.so.1 when compiling `build.rs` in dependencies. Since
# this used only at build time, we will use the version found in the gcc
# package proper--it won't find its way into the final binaries.
export LD_LIBRARY_PATH=$(pkg_path_for gcc)/lib

# Prost (our Rust protobuf library) embeds a `protoc` binary, but
# it's dynamically linked, which means it won't work in a
# Studio. Prost does allow us to override that, though, so we can
# just use our Habitat package by setting these two environment
# variables.
export PROTOC="$(pkg_path_for protobuf)/bin/protoc"
export PROTOC_INCLUDE="$(pkg_path_for protobuf)/include"

build_line "Setting LD_LIBRARY_PATH=$LD_LIBRARY_PATH"
}

do_build() {
export LIBRARY_PATH=$LIBZMQ_PREFIX/lib

pushd "$SRC_PATH" > /dev/null || exit
cargo build ${build_type#--debug} --target=$rustc_target --verbose --no-default-features \
--features apidocs
popd > /dev/null || exit
}

do_install() {
install -v -D "$CARGO_TARGET_DIR"/$rustc_target/${build_type#--}/$bin \
"$pkg_prefix"/bin/$bin
}

do_strip() {
if [[ "$build_type" != "--debug" ]]; then
strip --strip-debug "$pkg_prefix"/bin/$bin
fi
}
2 changes: 1 addition & 1 deletion test-services/test-probe/habitat/x86_64-linux/plan.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pkg_maintainer="The Habitat Maintainers <[email protected]>"
pkg_license=("Apache-2.0")
pkg_bin_dirs=(bin)
pkg_deps=(core/glibc
core/gcc-libs
core/gcc-base
core/procps-ng
core/bash)
pkg_build_deps=(core/coreutils
Expand Down

0 comments on commit a9eb966

Please sign in to comment.