more configs work now
``` make LIBC=gnu LINK=dynamic make LIBC=musl LINK=dynamic CC=musl-gcc make LIBC=musl LINK=static CC=musl-gcc ```
This commit is contained in:
parent
4d9c9e2ac4
commit
e824baa4ba
3 changed files with 41 additions and 35 deletions
|
@ -36,11 +36,8 @@ THIS_DIR := $(dir $(realpath $(lastword $(MAKEFILE_LIST))))
|
|||
REPO_ROOT := $(realpath $(THIS_DIR)/..)
|
||||
CARGO_OBJDIR := cargo/$(RUST_TARGET)/$(_profile)
|
||||
|
||||
# TODO: check if override is needed
|
||||
_rust_cli_profile := $(if $(filter $(_profile),debug),dev,$(_profile))
|
||||
|
||||
# TODO: `make LINK=static` fails with linker error "undefined reference to `_dl_find_object'" in libgcc_eh.a
|
||||
|
||||
STRIPFLAGS += -s --strip-unneeded -R .comment -R .gnu.version -R .note -R .note.gnu.build-id -R .note.ABI-tag
|
||||
STATIC_LINK_LIBS += -lservicepoint_binding_c
|
||||
|
||||
|
@ -57,7 +54,7 @@ CARGOFLAGS += --manifest-path=$(REPO_ROOT)/Cargo.toml \
|
|||
CFLAGS += -Wall -Wextra -pedantic -fwhole-program -fPIE -pie
|
||||
_no_debug_cflags := -ffunction-sections -fdata-sections -Wl,--gc-sections
|
||||
size_optimized_CFLAGS += -Oz \
|
||||
-fwrapv -fomit-frame-pointer -fno-stack-protector\
|
||||
-fwrapv -fomit-frame-pointer -fno-stack-protector \
|
||||
-fno-unroll-loops \
|
||||
-fno-unwind-tables -fno-asynchronous-unwind-tables \
|
||||
-fmerge-all-constants \
|
||||
|
@ -81,20 +78,25 @@ CFLAGS += $($(_libc)_CFLAGS) $($(_profile)_CFLAGS) $($(_link_type)_CFLAGS) $(_se
|
|||
ifeq ($(LTO), 1)
|
||||
CFLAGS += -flto
|
||||
endif
|
||||
ifeq ($(_libc),gnu)
|
||||
ifeq ($(_link_type),static)
|
||||
CFLAGS += $(error "statically linking glibc is known to be broken")
|
||||
endif
|
||||
endif
|
||||
|
||||
size_optimized_RUSTFLAGS += -Zlocation-detail=none \
|
||||
-Zfmt-debug=none \
|
||||
-C link-arg=-z,norelro \
|
||||
-C panic=abort
|
||||
#-C link-arg=--hash-style=gnu
|
||||
musl_RUSTFLAGS += --crate-type=staticlib -Ctarget-feature=-crt-static
|
||||
-C panic=abort \
|
||||
-C link-arg=-Wl,--hash-style=gnu
|
||||
static_RUSTFLAGS += --crate-type=staticlib -Ctarget-feature=+crt-static
|
||||
|
||||
RUSTFLAGS += $($(_libc)_RUSTFLAGS) $($(_profile)_RUSTFLAGS) $($(_link_type)_RUSTFLAGS)
|
||||
ifneq ($(_profile), debug)
|
||||
RUSTFLAGS += -C link-arg=-s -C link-arg=-Wl,--gc-sections
|
||||
endif
|
||||
|
||||
# TODO: wildcard does not work with VPATH
|
||||
# ADD NEW EXAMPLES HERE
|
||||
_c_src := src/announce.c src/brightness_tester.c src/header_logger.c \
|
||||
src/moving_line.c src/random_stuff.c src/wiping_clear.c
|
||||
_programs := $(basename $(notdir $(_c_src)))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue