diff --git a/Cargo.toml b/Cargo.toml index e20b5ec7e59b2..1473ff774111e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,6 +16,10 @@ name = "graphql-schema" path = "src/api/schema/gen.rs" required-features = ["default-no-api-client"] +[profile.release] +lto = true +codegen-units = 1 + [profile.bench] debug = true diff --git a/Makefile b/Makefile index fe7ad3b772c91..46636c8bc472b 100644 --- a/Makefile +++ b/Makefile @@ -163,6 +163,7 @@ environment-push: environment-prepare ## Publish a new version of the container ##@ Building .PHONY: build +build: export CFLAGS += -g0 -O3 build: ## Build the project in release mode (Supports `ENVIRONMENT=true`) ${MAYBE_ENVIRONMENT_EXEC} cargo build --release --no-default-features --features ${DEFAULT_FEATURES} ${MAYBE_ENVIRONMENT_COPY_ARTIFACTS} @@ -214,7 +215,7 @@ cross-%: export PAIR =$(subst -, ,$($(strip @):cross-%=%)) cross-%: export COMMAND ?=$(word 1,${PAIR}) cross-%: export TRIPLE ?=$(subst ${SPACE},-,$(wordlist 2,99,${PAIR})) cross-%: export PROFILE ?= release -cross-%: export RUSTFLAGS += -C link-arg=-s +cross-%: export CFLAGS += -g0 -O3 cross-%: cargo-install-cross $(MAKE) -k cross-image-${TRIPLE} cross ${COMMAND} \ @@ -226,7 +227,7 @@ cross-%: cargo-install-cross target/%/vector: export PAIR =$(subst /, ,$(@:target/%/vector=%)) target/%/vector: export TRIPLE ?=$(word 1,${PAIR}) target/%/vector: export PROFILE ?=$(word 2,${PAIR}) -target/%/vector: export RUSTFLAGS += -C link-arg=-s +target/%/vector: export CFLAGS += -g0 -O3 target/%/vector: cargo-install-cross CARGO_HANDLES_FRESHNESS $(MAKE) -k cross-image-${TRIPLE} cross build \ @@ -515,6 +516,7 @@ test-cli: ## Runs cli tests test-wasm-build-modules: $(WASM_MODULE_OUTPUTS) ### Build all WASM test modules $(WASM_MODULE_OUTPUTS): MODULE = $(notdir $@) +$(WASM_MODULE_OUTPUTS): export CFLAGS += -g0 -O3 $(WASM_MODULE_OUTPUTS): ### Build a specific WASM module @echo "# Building WASM module ${MODULE}, requires Rustc for wasm32-wasi." ${MAYBE_ENVIRONMENT_EXEC} cargo build \ diff --git a/scripts/build.sh b/scripts/build.sh index c6790a159225d..3cac17138a910 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -13,7 +13,6 @@ set -euo pipefail # $CHANNEL the release channel for the build, "nightly" or "stable" (default `scripts/release-channel.sh`) # $FEATURES a list of Vector features to include when building (default "default") # $NATIVE_BUILD whether to pass the --target flag when building via cargo (default "true") -# $KEEP_SYMBOLS whether to keep the any debug symbols in the binaries or not (default "true") # $TARGET a target triple. ex: x86_64-apple-darwin (no default) # @@ -23,7 +22,6 @@ set -euo pipefail OVERWRITE=${OVERWRITE:-"true"} FEATURES="${FEATURES:-"default"}" NATIVE_BUILD="${NATIVE_BUILD:-"true"}" -KEEP_SYMBOLS=${KEEP_SYMBOLS:-"true"} TARGET="${TARGET:?"You must specify a target triple, ex: x86_64-apple-darwin"}" CHANNEL=${CHANNEL:-"$(scripts/release-channel.sh)"} @@ -57,6 +55,12 @@ if [ -f "$BINARY_PATH" ] && [ "$OVERWRITE" == "false" ]; then exit 0 fi +# +# CFLAGS +# + +export CFLAGS="$CFLAGS -g0 -O3" + # # Header # @@ -65,7 +69,6 @@ echo "Building Vector binary" echo "OVERWRITE: $OVERWRITE" echo "FEATURES: $FEATURES" echo "NATIVE_BUILD: $NATIVE_BUILD" -echo "KEEP_SYMBOLS: $KEEP_SYMBOLS" echo "TARGET: $TARGET" echo "Binary path: $BINARY_PATH" @@ -84,11 +87,3 @@ if [ "$FEATURES" == "default" ]; then else cargo build "${BUILD_FLAGS[@]}" --no-default-features --features "$FEATURES" fi - -# -# Strip the output binary -# - -if [ "$KEEP_SYMBOLS" == "false" ]; then - strip "$BINARY_PATH" -fi diff --git a/scripts/slim-builds.sh b/scripts/slim-builds.sh index 3ccec5f329959..75fdffba4abac 100755 --- a/scripts/slim-builds.sh +++ b/scripts/slim-builds.sh @@ -19,18 +19,3 @@ cat <<-EOF >> ./.cargo/config # so we don't need to keep these around. incremental = false EOF - -cat <<-EOF >> ./Cargo.toml -[profile.release] -# See defaults https://doc.rust-lang.org/cargo/reference/profiles.html#release -opt-level = 3 -debug = false -debug-assertions = false -overflow-checks = false -lto = false -panic = 'unwind' -# Disabled, see build.incremental -# incremental = false -codegen-units = 1 -rpath = false -EOF