Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nix flake support (progress reports) #55

Open
jackyliu16 opened this issue May 26, 2023 · 13 comments
Open

Nix flake support (progress reports) #55

jackyliu16 opened this issue May 26, 2023 · 13 comments

Comments

@jackyliu16
Copy link
Contributor

jackyliu16 commented May 26, 2023

Background Information: I was trying to develop arceos in nixos and nix environment to minimize the impact of the development environment on the native environment, for example $PATH.
What i have done: I have completed the rCore support, arceos is in the process.

The arceos flakes only completed partial adaptation at this stage, x86_64 haven't supported yet, riscv64 and aarch64 has past all user test. My current progress could be seen in flake branch, which contains some change in the original file. If you have any suggestions or ideas about the problem, I would be very grateful.

[translation]

背景资料:我试图在 nixos and nix 环境中配置arceos的开发环境,以最大限度地减少开发环境对本地环境的影响,对于$PATH。
我做了什么:我已经完成了rCore支持arceos正在进行中。
arceos的flakes在这个阶段只完成了部分的适配,x86_64还没有支持,riscv 64和aarch 64目前通过了所有用户测试。
我的进度 可以在flake分支中看到,其中包含了对原文件的一些修改。如果你对这个问题有任何建议或想法,我将非常感激。

How could you synchronize my current progress (For nix user):

Current primary functionality is based on the devShells of nix flake, you should be able to open nix development environment though nix develop.
If there is any other error like experimental-feature, you should open /etc/nix/nix.conf add experimental-features=nix-commands flake to enable the experimental features.

@jackyliu16
Copy link
Contributor Author

jackyliu16 commented May 26, 2023

Current Application Support: make test ARCH=$(ARCH)

Application x86_64 aarch64 riscv64
hello ✔️ ✔️ ✔️
memtest ✔️ ✔️ ✔️
exception ✔️ ✔️ ✔️
task/yield ✔️ ✔️ ✔️
task/parallel ✔️ ✔️ ✔️
task/sleep ✔️ ✔️ ✔️
task/priority ✔️ ✔️ ✔️
net/httpclient ? ✔️ ✔️
c/helloworld ✔️ ✔️ ✔️
c/memtest ✔️ ✔️ ✔️
c/sqlite3 ✔️ ✔️ ✔️
c/httpclient ✔️ ✔️ ✔️

@jackyliu16
Copy link
Contributor Author

jackyliu16 commented May 26, 2023

Solved

c/sqlite3: Could not open 'disk.img': No such file or directory

#TODO

The file didn't say anything about the generate of disk.img will not be run automatic.
Not much is known about what the FS in the passed-in parameter does

ARCH=riscv64 LOG=info FS=y
    Building App: sqlite3, Arch: aarch64, Platform: qemu-virt-aarch64, Language: c
cargo rustc --target aarch64-unknown-none-softfloat --target-dir /home/jacky/Coding/arceos/target --release --crate-type staticlib --features "libax/platform-qemu-virt-aarch64 libax/log-level-warn libax/fs libax/default libax/fp_simd libax/alloc libax/paging libax/fs libax/cbindings"  --no-default-features -p libax -- -Clink-args="-T/home/jacky/Coding/arceos/modules/axhal/linker_aarch64.lds -no-pie"
    Finished release [optimized] target(s) in 0.20s
rm -f ulib/c_libax/build_aarch64/libc.a
aarch64-unknown-linux-musl-ar rc ulib/c_libax/build_aarch64/libc.a ulib/c_libax/build_aarch64/assert.o ulib/c_libax/build_aarch64/ctype.o ulib/c_libax/build_aarch64/errno.o ulib/c_libax/build_aarch64/fcntl.o ulib/c_libax/build_aarch64/mmap.o ulib/c_libax/build_aarch64/network.o ulib/c_libax/build_aarch64/pthread.o ulib/c_libax/build_aarch64/resource.o ulib/c_libax/build_aarch64/signal.o ulib/c_libax/build_aarch64/socket.o ulib/c_libax/build_aarch64/stat.o ulib/c_libax/build_aarch64/stdio.o ulib/c_libax/build_aarch64/stdlib.o ulib/c_libax/build_aarch64/string.o ulib/c_libax/build_aarch64/time.o ulib/c_libax/build_aarch64/unistd.o
aarch64-unknown-linux-musl-ranlib ulib/c_libax/build_aarch64/libc.a
    Linking apps/c/sqlite3/sqlite3_qemu-virt-aarch64.elf
rust-lld -flavor gnu -nostdlib -static -no-pie --gc-sections -T/home/jacky/Coding/arceos/modules/axhal/linker_aarch64.lds apps/c/sqlite3/main.o apps/c/sqlite3/sqlite3.o ulib/c_libax/build_aarch64/libc.a target/aarch64-unknown-none-softfloat/release/liblibax.a -o apps/c/sqlite3/sqlite3_qemu-virt-aarch64.elf
rust-objcopy --binary-architecture=aarch64 apps/c/sqlite3/sqlite3_qemu-virt-aarch64.elf --strip-all -O binary apps/c/sqlite3/sqlite3_qemu-virt-aarch64.bin
    Running qemu-system-aarch64 -m 128M -smp 1 -cpu cortex-a72 -machine virt -kernel apps/c/sqlite3/sqlite3_qemu-virt-aarch64.bin -device virtio-blk-device,drive=disk0 -drive id=disk0,if=none,format=raw,file=disk.img -nographic 
qemu-system-aarch64: -drive id=disk0,if=none,format=raw,file=disk.img: Could not open 'disk.img': No such file or directory
make: *** [Makefile:94:justrun] 错误 1

Complete process from build: source

ARCH=riscv64 LOG=info FS=y
    Building App: sqlite3, Arch: riscv64, Platform: qemu-virt-riscv, Language: c
cargo rustc --target riscv64gc-unknown-none-elf --target-dir /home/jacky/Coding/arceos/target --release --crate-type staticlib --features "libax/platform-qemu-virt-riscv libax/log-level-info libax/fs libax/default libax/fp_simd libax/alloc libax/paging libax/fs libax/cbindings"  --no-default-features -p libax -- -Clink-args="-T/home/jacky/Coding/arceos/modules/axhal/linker_riscv64.lds -no-pie"
   Compiling axconfig v0.1.0 (/home/jacky/Coding/arceos/modules/axconfig)
   Compiling axhal v0.1.0 (/home/jacky/Coding/arceos/modules/axhal)
   Compiling libax v0.1.0 (/home/jacky/Coding/arceos/ulib/libax)
   Compiling axtask v0.1.0 (/home/jacky/Coding/arceos/modules/axtask)
   Compiling axdriver v0.1.0 (/home/jacky/Coding/arceos/modules/axdriver)
   Compiling axsync v0.1.0 (/home/jacky/Coding/arceos/modules/axsync)
   Compiling axfs v0.1.0 (/home/jacky/Coding/arceos/modules/axfs)
   Compiling axruntime v0.1.0 (/home/jacky/Coding/arceos/modules/axruntime)
    Finished release [optimized] target(s) in 8.57s
riscv64-unknown-linux-musl-gcc -DAX_CONFIG_DEFAULT -DAX_CONFIG_FP_SIMD -DAX_CONFIG_ALLOC -DAX_CONFIG_PAGING -DAX_CONFIG_FS -nostdinc -static -no-pie -fno-builtin -ffreestanding -Wall -Iulib/c_libax/include -Iulib/c_libax/../libax -O3 -march=rv64gc -mabi=lp64d -mcmodel=medany -DSQLITE_THREADSAFE=0 -DSQLITE_OMIT_FLOATING_POINT -DSQLITE_OMIT_LOAD_EXTENSION -DSQLITE_DEBUG -w -c -o apps/c/sqlite3/sqlite3.o apps/c/sqlite3/sqlite3.c
mkdir -p ulib/c_libax/build_riscv64
riscv64-unknown-linux-musl-gcc -DAX_CONFIG_DEFAULT -DAX_CONFIG_FP_SIMD -DAX_CONFIG_ALLOC -DAX_CONFIG_PAGING -DAX_CONFIG_FS -nostdinc -static -no-pie -fno-builtin -ffreestanding -Wall -Iulib/c_libax/include -Iulib/c_libax/../libax -O3 -march=rv64gc -mabi=lp64d -mcmodel=medany -c -o ulib/c_libax/build_riscv64/assert.o ulib/c_libax/src/assert.c
riscv64-unknown-linux-musl-gcc -DAX_CONFIG_DEFAULT -DAX_CONFIG_FP_SIMD -DAX_CONFIG_ALLOC -DAX_CONFIG_PAGING -DAX_CONFIG_FS -nostdinc -static -no-pie -fno-builtin -ffreestanding -Wall -Iulib/c_libax/include -Iulib/c_libax/../libax -O3 -march=rv64gc -mabi=lp64d -mcmodel=medany -c -o ulib/c_libax/build_riscv64/ctype.o ulib/c_libax/src/ctype.c
riscv64-unknown-linux-musl-gcc -DAX_CONFIG_DEFAULT -DAX_CONFIG_FP_SIMD -DAX_CONFIG_ALLOC -DAX_CONFIG_PAGING -DAX_CONFIG_FS -nostdinc -static -no-pie -fno-builtin -ffreestanding -Wall -Iulib/c_libax/include -Iulib/c_libax/../libax -O3 -march=rv64gc -mabi=lp64d -mcmodel=medany -c -o ulib/c_libax/build_riscv64/errno.o ulib/c_libax/src/errno.c
riscv64-unknown-linux-musl-gcc -DAX_CONFIG_DEFAULT -DAX_CONFIG_FP_SIMD -DAX_CONFIG_ALLOC -DAX_CONFIG_PAGING -DAX_CONFIG_FS -nostdinc -static -no-pie -fno-builtin -ffreestanding -Wall -Iulib/c_libax/include -Iulib/c_libax/../libax -O3 -march=rv64gc -mabi=lp64d -mcmodel=medany -c -o ulib/c_libax/build_riscv64/fcntl.o ulib/c_libax/src/fcntl.c
riscv64-unknown-linux-musl-gcc -DAX_CONFIG_DEFAULT -DAX_CONFIG_FP_SIMD -DAX_CONFIG_ALLOC -DAX_CONFIG_PAGING -DAX_CONFIG_FS -nostdinc -static -no-pie -fno-builtin -ffreestanding -Wall -Iulib/c_libax/include -Iulib/c_libax/../libax -O3 -march=rv64gc -mabi=lp64d -mcmodel=medany -c -o ulib/c_libax/build_riscv64/mmap.o ulib/c_libax/src/mmap.c
riscv64-unknown-linux-musl-gcc -DAX_CONFIG_DEFAULT -DAX_CONFIG_FP_SIMD -DAX_CONFIG_ALLOC -DAX_CONFIG_PAGING -DAX_CONFIG_FS -nostdinc -static -no-pie -fno-builtin -ffreestanding -Wall -Iulib/c_libax/include -Iulib/c_libax/../libax -O3 -march=rv64gc -mabi=lp64d -mcmodel=medany -c -o ulib/c_libax/build_riscv64/network.o ulib/c_libax/src/network.c
riscv64-unknown-linux-musl-gcc -DAX_CONFIG_DEFAULT -DAX_CONFIG_FP_SIMD -DAX_CONFIG_ALLOC -DAX_CONFIG_PAGING -DAX_CONFIG_FS -nostdinc -static -no-pie -fno-builtin -ffreestanding -Wall -Iulib/c_libax/include -Iulib/c_libax/../libax -O3 -march=rv64gc -mabi=lp64d -mcmodel=medany -c -o ulib/c_libax/build_riscv64/pthread.o ulib/c_libax/src/pthread.c
riscv64-unknown-linux-musl-gcc -DAX_CONFIG_DEFAULT -DAX_CONFIG_FP_SIMD -DAX_CONFIG_ALLOC -DAX_CONFIG_PAGING -DAX_CONFIG_FS -nostdinc -static -no-pie -fno-builtin -ffreestanding -Wall -Iulib/c_libax/include -Iulib/c_libax/../libax -O3 -march=rv64gc -mabi=lp64d -mcmodel=medany -c -o ulib/c_libax/build_riscv64/resource.o ulib/c_libax/src/resource.c
riscv64-unknown-linux-musl-gcc -DAX_CONFIG_DEFAULT -DAX_CONFIG_FP_SIMD -DAX_CONFIG_ALLOC -DAX_CONFIG_PAGING -DAX_CONFIG_FS -nostdinc -static -no-pie -fno-builtin -ffreestanding -Wall -Iulib/c_libax/include -Iulib/c_libax/../libax -O3 -march=rv64gc -mabi=lp64d -mcmodel=medany -c -o ulib/c_libax/build_riscv64/signal.o ulib/c_libax/src/signal.c
riscv64-unknown-linux-musl-gcc -DAX_CONFIG_DEFAULT -DAX_CONFIG_FP_SIMD -DAX_CONFIG_ALLOC -DAX_CONFIG_PAGING -DAX_CONFIG_FS -nostdinc -static -no-pie -fno-builtin -ffreestanding -Wall -Iulib/c_libax/include -Iulib/c_libax/../libax -O3 -march=rv64gc -mabi=lp64d -mcmodel=medany -c -o ulib/c_libax/build_riscv64/socket.o ulib/c_libax/src/socket.c
riscv64-unknown-linux-musl-gcc -DAX_CONFIG_DEFAULT -DAX_CONFIG_FP_SIMD -DAX_CONFIG_ALLOC -DAX_CONFIG_PAGING -DAX_CONFIG_FS -nostdinc -static -no-pie -fno-builtin -ffreestanding -Wall -Iulib/c_libax/include -Iulib/c_libax/../libax -O3 -march=rv64gc -mabi=lp64d -mcmodel=medany -c -o ulib/c_libax/build_riscv64/stat.o ulib/c_libax/src/stat.c
riscv64-unknown-linux-musl-gcc -DAX_CONFIG_DEFAULT -DAX_CONFIG_FP_SIMD -DAX_CONFIG_ALLOC -DAX_CONFIG_PAGING -DAX_CONFIG_FS -nostdinc -static -no-pie -fno-builtin -ffreestanding -Wall -Iulib/c_libax/include -Iulib/c_libax/../libax -O3 -march=rv64gc -mabi=lp64d -mcmodel=medany -c -o ulib/c_libax/build_riscv64/stdio.o ulib/c_libax/src/stdio.c
riscv64-unknown-linux-musl-gcc -DAX_CONFIG_DEFAULT -DAX_CONFIG_FP_SIMD -DAX_CONFIG_ALLOC -DAX_CONFIG_PAGING -DAX_CONFIG_FS -nostdinc -static -no-pie -fno-builtin -ffreestanding -Wall -Iulib/c_libax/include -Iulib/c_libax/../libax -O3 -march=rv64gc -mabi=lp64d -mcmodel=medany -c -o ulib/c_libax/build_riscv64/stdlib.o ulib/c_libax/src/stdlib.c
riscv64-unknown-linux-musl-gcc -DAX_CONFIG_DEFAULT -DAX_CONFIG_FP_SIMD -DAX_CONFIG_ALLOC -DAX_CONFIG_PAGING -DAX_CONFIG_FS -nostdinc -static -no-pie -fno-builtin -ffreestanding -Wall -Iulib/c_libax/include -Iulib/c_libax/../libax -O3 -march=rv64gc -mabi=lp64d -mcmodel=medany -c -o ulib/c_libax/build_riscv64/string.o ulib/c_libax/src/string.c
riscv64-unknown-linux-musl-gcc -DAX_CONFIG_DEFAULT -DAX_CONFIG_FP_SIMD -DAX_CONFIG_ALLOC -DAX_CONFIG_PAGING -DAX_CONFIG_FS -nostdinc -static -no-pie -fno-builtin -ffreestanding -Wall -Iulib/c_libax/include -Iulib/c_libax/../libax -O3 -march=rv64gc -mabi=lp64d -mcmodel=medany -c -o ulib/c_libax/build_riscv64/time.o ulib/c_libax/src/time.c
riscv64-unknown-linux-musl-gcc -DAX_CONFIG_DEFAULT -DAX_CONFIG_FP_SIMD -DAX_CONFIG_ALLOC -DAX_CONFIG_PAGING -DAX_CONFIG_FS -nostdinc -static -no-pie -fno-builtin -ffreestanding -Wall -Iulib/c_libax/include -Iulib/c_libax/../libax -O3 -march=rv64gc -mabi=lp64d -mcmodel=medany -c -o ulib/c_libax/build_riscv64/unistd.o ulib/c_libax/src/unistd.c
rm -f ulib/c_libax/build_riscv64/libc.a
riscv64-unknown-linux-musl-ar rc ulib/c_libax/build_riscv64/libc.a ulib/c_libax/build_riscv64/assert.o ulib/c_libax/build_riscv64/ctype.o ulib/c_libax/build_riscv64/errno.o ulib/c_libax/build_riscv64/fcntl.o ulib/c_libax/build_riscv64/mmap.o ulib/c_libax/build_riscv64/network.o ulib/c_libax/build_riscv64/pthread.o ulib/c_libax/build_riscv64/resource.o ulib/c_libax/build_riscv64/signal.o ulib/c_libax/build_riscv64/socket.o ulib/c_libax/build_riscv64/stat.o ulib/c_libax/build_riscv64/stdio.o ulib/c_libax/build_riscv64/stdlib.o ulib/c_libax/build_riscv64/string.o ulib/c_libax/build_riscv64/time.o ulib/c_libax/build_riscv64/unistd.o
riscv64-unknown-linux-musl-ranlib ulib/c_libax/build_riscv64/libc.a
    Linking apps/c/sqlite3/sqlite3_qemu-virt-riscv.elf
rust-lld -flavor gnu -nostdlib -static -no-pie --gc-sections -T/home/jacky/Coding/arceos/modules/axhal/linker_riscv64.lds --no-relax apps/c/sqlite3/main.o apps/c/sqlite3/sqlite3.o ulib/c_libax/build_riscv64/libc.a target/riscv64gc-unknown-none-elf/release/liblibax.a -o apps/c/sqlite3/sqlite3_qemu-virt-riscv.elf
rust-objcopy --binary-architecture=riscv64 apps/c/sqlite3/sqlite3_qemu-virt-riscv.elf --strip-all -O binary apps/c/sqlite3/sqlite3_qemu-virt-riscv.bin
    Running qemu-system-riscv64 -m 128M -smp 1 -machine virt -bios default -kernel apps/c/sqlite3/sqlite3_qemu-virt-riscv.bin -device virtio-blk-device,drive=disk0 -drive id=disk0,if=none,format=raw,file=disk.img -nographic 
qemu-system-riscv64: -drive id=disk0,if=none,format=raw,file=disk.img: Could not open 'disk.img': No such file or directory
make: *** [Makefile:94:justrun] 错误 1

Complete process from build: source

@jackyliu16
Copy link
Contributor Author

jackyliu16 commented May 26, 2023

Solved

c/helloworld: relocation R_X86_64_32 out of range
It looks a little bit like Relocation R_X86_64_32S out of range #70992, maybe required further analysis of internal links.

ARCH=x86_64 LOG=info FS=y
rm -f ulib/c_libax/build_x86_64/libc.a
x86_64-unknown-linux-musl-ar rc ulib/c_libax/build_x86_64/libc.a ulib/c_libax/build_x86_64/assert.o ulib/c_libax/build_x86_64/ctype.o ulib/c_libax/build_x86_64/errno.o ulib/c_libax/build_x86_64/fcntl.o ulib/c_libax/build_x86_64/mmap.o ulib/c_libax/build_x86_64/network.o ulib/c_libax/build_x86_64/pthread.o ulib/c_libax/build_x86_64/resource.o ulib/c_libax/build_x86_64/signal.o ulib/c_libax/build_x86_64/socket.o ulib/c_libax/build_x86_64/stat.o ulib/c_libax/build_x86_64/stdio.o ulib/c_libax/build_x86_64/stdlib.o ulib/c_libax/build_x86_64/string.o ulib/c_libax/build_x86_64/time.o ulib/c_libax/build_x86_64/unistd.o
x86_64-unknown-linux-musl-ranlib ulib/c_libax/build_x86_64/libc.a
    Linking apps/c/helloworld//helloworld_pc-x86.elf
rust-lld -flavor gnu -nostdlib -static -no-pie --gc-sections -T/home/jacky/Coding/arceos/modules/axhal/linker_x86_64.lds apps/c/helloworld//main.o ulib/c_libax/build_x86_64/libc.a target/x86_64-unknown-none/release/liblibax.a -o apps/c/helloworld//helloworld_pc-x86.elf
rust-lld: error: apps/c/helloworld//main.o:(function main: .text.startup+0x11): relocation R_X86_64_32 out of range: 18446743523956043783 is not in [0, 4294967295]
>>> referenced by main.c

rust-lld: error: ulib/c_libax/build_x86_64/libc.a(stdio.o):(function parsenint: .text+0x46): relocation R_X86_64_32S out of range: -549753507376 is not in [-2147483648, 2147483647]
>>> referenced by stdio.c

rust-lld: error: ulib/c_libax/build_x86_64/libc.a(stdio.o):(function parsenint: .text+0xc9): relocation R_X86_64_32 out of range: 18446743523956044208 is not in [0, 4294967295]
>>> referenced by stdio.c

rust-lld: error: ulib/c_libax/build_x86_64/libc.a(stdio.o):(function parsenint: .text+0xd3): relocation R_X86_64_32 out of range: 18446743523956043806 is not in [0, 4294967295]
>>> referenced by stdio.c

rust-lld: error: ulib/c_libax/build_x86_64/libc.a(stdio.o):(function parsenint: .text+0xd8): relocation R_X86_64_32 out of range: 18446743523956043776 is not in [0, 4294967295]
>>> referenced by stdio.c

rust-lld: error: ulib/c_libax/build_x86_64/libc.a(stdio.o):(function printint: .text+0x135): relocation R_X86_64_32S out of range: -549753507376 is not in [-2147483648, 2147483647]
>>> referenced by stdio.c

rust-lld: error: ulib/c_libax/build_x86_64/libc.a(stdio.o):(function printint: .text+0x19d): relocation R_X86_64_32S out of range: -549753167840 is not in [-2147483648, 2147483647]
>>> referenced by stdio.c

rust-lld: error: ulib/c_libax/build_x86_64/libc.a(stdio.o):(function printint: .text+0x1b3): relocation R_X86_64_32 out of range: 18446743523956383776 is not in [0, 4294967295]
>>> referenced by stdio.c

rust-lld: error: ulib/c_libax/build_x86_64/libc.a(stdio.o):(function printint: .text+0x1ec): relocation R_X86_64_32 out of range: 18446743523956044224 is not in [0, 4294967295]
>>> referenced by stdio.c

rust-lld: error: ulib/c_libax/build_x86_64/libc.a(stdio.o):(function printint: .text+0x1f6): relocation R_X86_64_32 out of range: 18446743523956043806 is not in [0, 4294967295]
>>> referenced by stdio.c

rust-lld: error: ulib/c_libax/build_x86_64/libc.a(stdio.o):(function printint: .text+0x1fb): relocation R_X86_64_32 out of range: 18446743523956043776 is not in [0, 4294967295]
>>> referenced by stdio.c

rust-lld: error: ulib/c_libax/build_x86_64/libc.a(stdio.o):(function fflush: .text+0x240): relocation R_X86_64_32 out of range: 18446743523956383776 is not in [0, 4294967295]
>>> referenced by stdio.c

rust-lld: error: ulib/c_libax/build_x86_64/libc.a(stdio.o):(function putchar: .text+0x26d): relocation R_X86_64_32S out of range: -549753167840 is not in [-2147483648, 2147483647]
>>> referenced by stdio.c

rust-lld: error: ulib/c_libax/build_x86_64/libc.a(stdio.o):(function putchar: .text+0x298): relocation R_X86_64_32 out of range: 18446743523956383776 is not in [0, 4294967295]
>>> referenced by stdio.c

rust-lld: error: ulib/c_libax/build_x86_64/libc.a(stdio.o):(function fprintf: .text+0x3ad): relocation R_X86_64_32S out of range: -549753167840 is not in [-2147483648, 2147483647]
>>> referenced by stdio.c

rust-lld: error: ulib/c_libax/build_x86_64/libc.a(stdio.o):(function fprintf: .text+0x3c3): relocation R_X86_64_32 out of range: 18446743523956383776 is not in [0, 4294967295]
>>> referenced by stdio.c

rust-lld: error: ulib/c_libax/build_x86_64/libc.a(stdio.o):(function fprintf: .text+0x415): relocation R_X86_64_32S out of range: -549753507760 is not in [-2147483648, 2147483647]
>>> referenced by stdio.c

rust-lld: error: ulib/c_libax/build_x86_64/libc.a(stdio.o):(function fprintf: .text+0x42c): relocation R_X86_64_32S out of range: -549753167840 is not in [-2147483648, 2147483647]
>>> referenced by stdio.c

rust-lld: error: ulib/c_libax/build_x86_64/libc.a(stdio.o):(function fprintf: .text+0x452): relocation R_X86_64_32S out of range: -549753167840 is not in [-2147483648, 2147483647]
>>> referenced by stdio.c

rust-lld: error: ulib/c_libax/build_x86_64/libc.a(stdio.o):(function fprintf: .text+0x500): relocation R_X86_64_32 out of range: 18446743523956043799 is not in [0, 4294967295]
>>> referenced by stdio.c

rust-lld: error: too many errors emitted, stopping now (use --error-limit=0 to see all errors)
make: *** [ulib/c_libax/build.mk:74:apps/c/helloworld//helloworld_pc-x86.elf] 错误 1

Complete process from build: source

@equation314
Copy link
Member

Solved

c/sqlite3: Could not open 'disk.img': No such file or directory

#TODO

The file didn't say anything about the generate of disk.img will not be run automatic.
Not much is known about what the FS in the passed-in parameter does

ARCH=riscv64 LOG=info FS=y
Complete process from build: source

ARCH=riscv64 LOG=info FS=y
Complete process from build: source

Run make disk_img before.

@jackyliu16
Copy link
Contributor Author

jackyliu16 commented May 26, 2023

Run make disk_img before.

Yes, the problem has been solved by that ways, I was thinking if we should change Makefile to make disk_img as a dependence of build, just like this.

@equation314
Copy link
Member

equation314 commented May 28, 2023

It should not be a dependency, otherwise redundant warning information will be output, and not all applications use disk.img.

@jackyliu16
Copy link
Contributor Author

It seems that when developing on a environment haven't install rust before, will cases cargo --version does not specify a version and therefore cannot be debugged properly using rust-analyzer

@leelingrui
Copy link

c/helloworld: relocation R_X86_64_32 out of range It looks a little bit like Relocation R_X86_64_32S out of range #70992, maybe required further analysis of internal links.

ARCH=x86_64 LOG=info FS=y
Complete process from build: source

have you solved this problem?

@equation314
Copy link
Member

Add --no-relax to LDFLAGS?

@jackyliu16
Copy link
Contributor Author

jackyliu16 commented Jul 21, 2023

c/helloworld: relocation R_X86_64_32 out of range It looks a little bit like Relocation R_X86_64_32S out of range #70992, maybe required further analysis of internal links.
ARCH=x86_64 LOG=info FS=y
Complete process from build: source

have you solved this problem?

Actually, the problem has been solved when I'm trying not to use the musl tool chain provide by nixpkgs.
This is my current script and it's lock file, it has been test in the arceos (rcore-os/arceos:79ecfaa40ec68b8f6081619bcdf0fa111762b7d9)
Because I downloaded the recommended tool chain directly using fetchurl

by the ways, this is the commands to using the devShells, if you just only have one, you can just using full as default and using direnv:

$ nix develop .#full --option substituters https://mirror.iscas.ac.cn/nix-channels/store --ignore-environment 

@leelingrui
Copy link

leelingrui commented Jul 21, 2023

Actually, the problem has been solved when I'm trying not to use the musl tool chain provide by nixpkgs. This is my current script and it's lock file, it has been test in the arceos (rcore-os/arceos:79ecfaa40ec68b8f6081619bcdf0fa111762b7d9) Because I downloaded the recommended tool chain directly using fetchurl

by the ways, this is the commands to using the devShells, if you just only have one, you can just using full as default and using direnv:

$ nix develop .#full --option substituters https://mirror.iscas.ac.cn/nix-channels/store --ignore-environment 

my tool chain is x86_64-unknown-none
i want to link my kernel to high address but encounter relocation R_X86_64_32S out of range is happened at inline assembly

        asm!(
            "lgdt [GDT_PTR]" 
        ); //GDT_PTR is gdt entry
        asm!(
            "lidt [IDT_PTR]" 
        ); //IDT_PTR is idt entry
        call [HANDLER_TABLE + rax * 8]

it works properly at 0x100000, but when i change linker.ld link it to 0xffff800000100000 error occured

OUTPUT_ARCH(x86_64)
ENTRY(_start)
BASE_ADDRESS = 0xffff800000100000;

SECTIONS
{
    . = BASE_ADDRESS;
    skernel = .;

    stext = .;
    .text : {
        *(.text.entry)
        *(.text .text.*)
    }

    . = ALIGN(4K);
    .dynamic : {
        *(.dynamic)
    }
    
    . = ALIGN(4K);
    .got : {
        *(.got)
    }

    . = ALIGN(4K);
    erodata = .;
    sdata = .;
    .data : {
        *(.data .data.*)
        *(.sdata .sdata.*)
    }

    . = ALIGN(4K);
    etext = .;
    srodata = .;
    .rodata : {
        *(.rodata .rodata.*)
        *(.srodata .srodata.*)
    }

    . = ALIGN(4K);
    edata = .;
    .bss : {
        *(.bss.stack)
        sbss = .;
        *(.bss .bss.*)
        *(.sbss .sbss.*)
    }
    . = ALIGN(4K);
    dyn = .;
    .dynsym :
    {
        *(.dynsym)
    }
    .gnu.hash : {
        *(.gnu.hash)
    }
    .hash :
    {
        *(.hash)
    }
    . = ALIGN(4K);
    ebss = .;
    ekernel = .;

    /DISCARD/ : {
        *(.eh_frame)
    }
}

this afternoon i watched binary code of lgdt [GDT_PTR] i found the binary code is
image
image
i have searched some information the 0x0F 0x01 is LGDT Opcode 0x14 means use SIB addressing mode 0x25,
means SIB form is disp32, last 4 bytes is address of GDT_PTR.
that's why it can work at 0x100000 but can't work at 0xffff800000100000.

but i don't know how to tell complier reserve 8 bytes for me.

@jackyliu16
Copy link
Contributor Author

jackyliu16 commented Jul 22, 2023

@leelingrui Maybe it's because my knowledge is relatively narrow, I can't quite understand what you said (

@leelingrui
Copy link

leelingrui commented Jul 23, 2023

@jackyliu16 may be my expressive ability is too bad, I already solved this problem.I still appreciate your help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants