Skip to content

Commit

Permalink
Disable x86_64-specific relaxation on linkage
Browse files Browse the repository at this point in the history
It fixes `relocation R_X86_64_REX_GOTPCRELX out of range` on
the latest nightly rust version (>= 2023-08-25) with llvm 17
  • Loading branch information
equation314 committed Aug 27, 2023
1 parent e526753 commit 94eeaa3
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 11 deletions.
5 changes: 0 additions & 5 deletions apps/c/redis/axbuild.mk
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@ redis-objs := redis-$(redis-version)/src/redis-server.o
app-objs := $(redis-objs)

CFLAGS += -Wno-format
ifeq ($(AX_ARCH), x86_64)
CFLAGS += -mcmodel=large
else ifeq ($(ARCH), riscv64)
LDFLAGS += --no-relax
endif

redis-build-args := \
CC=$(CC) \
Expand Down
4 changes: 0 additions & 4 deletions apps/c/sqlite3/axbuild.mk
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@ sqlite3_dir := $(APP)/$(sqlite3_pkg)
APP_CFLAGS := -I$(sqlite3_dir) -w \
-DSQLITE_THREADSAFE=0 -DSQLITE_OMIT_FLOATING_POINT -DSQLITE_OMIT_LOAD_EXTENSION -DSQLITE_DEBUG

ifeq ($(ARCH), riscv64)
LDFLAGS += --no-relax
endif

app-objs := main.o $(sqlite3_pkg)/sqlite3.o

$(APP)/main.o: $(sqlite3_dir)/sqlite3.c
Expand Down
6 changes: 4 additions & 2 deletions scripts/make/build_c.mk
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,17 @@ ulib_obj := $(patsubst $(src_dir)/%.c,$(obj_dir)/%.o,$(ulib_src))
CFLAGS += $(addprefix -DAX_CONFIG_,$(shell echo $(lib_feat) | tr 'a-z' 'A-Z' | tr '-' '_'))
CFLAGS += -DAX_LOG_$(shell echo $(LOG) | tr 'a-z' 'A-Z')

CFLAGS += -nostdinc -static -no-pie -fno-builtin -ffreestanding -Wall
CFLAGS += -nostdinc -fno-builtin -ffreestanding -Wall
CFLAGS += -I$(CURDIR)/$(inc_dir)
LDFLAGS += -nostdlib -static -no-pie --gc-sections -T$(LD_SCRIPT)

ifeq ($(MODE), release)
CFLAGS += -O3
endif

ifeq ($(ARCH), riscv64)
ifeq ($(ARCH), x86_64)
LDFLAGS += --no-relax
else ifeq ($(ARCH), riscv64)
CFLAGS += -march=rv64gc -mabi=lp64d -mcmodel=medany
endif

Expand Down
4 changes: 4 additions & 0 deletions scripts/make/cargo.mk
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ build_args := \
RUSTFLAGS := -C link-arg=-T$(LD_SCRIPT) -C link-arg=-no-pie
RUSTDOCFLAGS := --enable-index-page -Zunstable-options -D rustdoc::broken_intra_doc_links

ifeq ($(ARCH), x86_64)
RUSTFLAGS += -C link-arg=--no-relax
endif

ifeq ($(MAKECMDGOALS), doc_check_missing)
RUSTDOCFLAGS += -D missing-docs
endif
Expand Down

0 comments on commit 94eeaa3

Please sign in to comment.