fix many configurations
Some checks failed
Rust / build (pull_request) Failing after 3m22s

This commit is contained in:
Vinzenz Schroeter 2025-05-03 19:15:20 +02:00
parent 04223022a2
commit bfef70f686
6 changed files with 59 additions and 53 deletions

View file

@ -1,7 +1,7 @@
CARGO ?= rustup run nightly cargo
CARGO ?= cargo
STRIP ?= strip
FEATURES := protocol_udp
FEATURES :=
THIS_DIR := $(dir $(realpath $(lastword $(MAKEFILE_LIST))))
REPO_ROOT := $(realpath $(THIS_DIR)/..)
@ -10,42 +10,31 @@ export SERVICEPOINT_HEADER_OUT := $(REPO_ROOT)/include
override CFG_MUSL := $(if $(CFG_MUSL),$(CFG_MUSL),$(if $(MUSL),$(MUSL),0))
override CFG_PROFILE := $(if $(CFG_PROFILE),$(CFG_PROFILE),$(if $(PROFILE),$(PROFILE),release))
CCFLAGS += -ffunction-sections -fdata-sections -Wl,--gc-sections -Wall -fwhole-program
RUSTFLAGS += -C link-arg=-s \
-C link-arg=-Wl,--gc-sections \
--crate-type=staticlib
CCFLAGS += -Wall -fwhole-program
STRIPFLAGS := -s --strip-unneeded -R .comment -R .gnu.version -R .note -R .note.gnu.build-id -R .note.ABI-tag
ifeq ($(CFG_MUSL), 1)
TARGET ?= x86_64-unknown-linux-musl
CC ?= musl-gcc
CCFLAGS += -static
CCFLAGS += -static -lservicepoint_binding_c
RUSTFLAGS += --crate-type=staticlib
else
TARGET ?= x86_64-unknown-linux-gnu
CC ?= gcc
CCFLAGS += -shared
#CCFLAGS += -shared
CCFLAGS += -Wl,-Bstatic -lservicepoint_binding_c -Wl,-Bdynamic
endif
RUSTFLAGS += -C linker=$(CC)
#ifeq ($(CFG_PROFILE), size-optimized)
# CCFLAGS += -nodefaultlibs -lc
#endif
CCFLAGS += -lservicepoint_binding_c
RUST_TARGET_DIR := $(REPO_ROOT)/target/$(TARGET)/$(CFG_PROFILE)
OUT_BASE_DIR := $(realpath $(THIS_DIR)/out/)
OUT_DIR := $(realpath $(OUT_BASE_DIR)/$(CFG_PROFILE)/)
CARGOFLAGS += --manifest-path=$(REPO_ROOT)/Cargo.toml \
--profile=$(CFG_PROFILE) \
--no-default-features \
--features=$(FEATURES) \
--target=$(TARGET)
OUT_DIR := $(realpath $(THIS_DIR)/out/)
ifeq ($(CFG_PROFILE), size-optimized)
CARGO_PROFILE := size-optimized
CCFLAGS += -Oz \
-fwrapv -fomit-frame-pointer -fno-stack-protector\
-fno-unroll-loops \
@ -63,16 +52,29 @@ ifeq ($(CFG_PROFILE), size-optimized)
RUSTFLAGS += -Zlocation-detail=none \
-Zfmt-debug=none \
-C link-arg=-z,norelro \
-C link-arg=--hash-style=gnu \
-C panic=abort
#-C link-arg=--hash-style=gnu
else ifeq ($(CFG_PROFILE), release)
CARGO_PROFILE := release
CCFLAGS += -O2
else ifeq ($(CFG_PROFILE), debug)
CCFLAGS += -Og
CARGO_PROFILE := dev
else
CFG_PROFILE := $(error "PROFILE has to be set to one of: debug, release, size-optimized")
endif
CARGOFLAGS += --manifest-path=$(REPO_ROOT)/Cargo.toml \
--profile=$(CARGO_PROFILE) \
--no-default-features \
--features=$(FEATURES) \
--target=$(TARGET)
ifneq ($(CFG_PROFILE), debug)
CCFLAGS += -ffunction-sections -fdata-sections -Wl,--gc-sections
RUSTFLAGS += -C link-arg=-s -C link-arg=-Wl,--gc-sections
endif
ifeq ($(LTO), 1)
CCFLAGS += -flto
endif
@ -87,12 +89,16 @@ _sp_artifacts := $(SERVICEPOINT_HEADER_OUT)/servicepoint.h $(RUST_TARGET_DIR)/li
all: $(_bins)
clean:
echo rm -r $(OUT_DIR) || true
clean: clean-c clean-rust
clean-c:
rm -r $(OUT_DIR) || true
clean-rust:
rm $(SERVICEPOINT_HEADER_OUT)/servicepoint.h || true
cargo clean
.PHONY: all clean sizes $(_run_programs)
.PHONY: all clean sizes $(_run_programs) clean-c clean-rust
$(_unstripped_bins): out/%_unstripped: src/%.c $(SERVICEPOINT_HEADER_OUT)/servicepoint.h $(_sp_artifacts)
mkdir -p out || true
@ -116,7 +122,7 @@ $(_run_programs): run_%: out/% FORCE
sizes: $(_bins)
ls -lB out
analyze-size: $(OUT_DIR)/$(BIN)_unstripped
analyze-size: out/$(BIN)_unstripped
nm --print-size --size-sort --reverse-sort --radix=d --demangle $(OUT_DIR)/$(BIN)_unstripped \
| awk '{size=$$2+0; print size "\t" $$4}' \
| less

View file

@ -1,8 +1,12 @@
#include <stdio.h>
#include "servicepoint.h"
int main(void) {
//UdpConnection *connection = sp_udp_open_ipv4(172, 23, 42, 29, 2342);
UdpConnection *connection = sp_udp_open_ipv4(127, 0, 0, 1, 2342);
printf("test\n");
UdpSocket *connection = sp_udp_open_ipv4(172, 23, 42, 29, 2342);
//UdpSocket *connection = sp_udp_open_ipv4(127, 0, 0, 1, 2342);
if (connection == NULL)
return 1;
@ -11,7 +15,7 @@ int main(void) {
CharGrid *grid = sp_char_grid_new(5, 2);
if (grid == NULL)
return 1;
sp_char_grid_set(grid, 0, 0, 'H');
sp_char_grid_set(grid, 1, 0, 'e');
sp_char_grid_set(grid, 2, 0, 'l');

View file

@ -1,8 +1,8 @@
#include "servicepoint.h"
int main(void) {
// UdpConnection *connection = sp_udp_open_ipv4(172, 23, 42, 29, 2342);
UdpConnection *connection = sp_udp_open_ipv4(127, 0, 0, 1, 2342);
UdpSocket *connection = sp_udp_open_ipv4(172, 23, 42, 29, 2342);
//UdpSocket *connection = sp_udp_open_ipv4(127, 0, 0, 1, 2342);
if (connection == NULL)
return -1;

View file

@ -1,9 +1,7 @@
//#include <stdarg.h>
#include "servicepoint.h"
//#include <stdio.h>
int main(void) {
UdpConnection *connection = sp_udp_open_ipv4(127, 0, 0, 1, 2342);
UdpSocket *connection = sp_udp_open_ipv4(127, 0, 0, 1, 2342);
if (connection == NULL)
return 1;