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

Cannot cross-compile on an x86_64 PC #112

Open
atorregr opened this issue Sep 5, 2024 · 2 comments
Open

Cannot cross-compile on an x86_64 PC #112

atorregr opened this issue Sep 5, 2024 · 2 comments

Comments

@atorregr
Copy link

atorregr commented Sep 5, 2024

I can download and compile the rtl8189fs driver on an ARM64 device. However I wasn't able to cross-compile on an x86_64 device, such as my own PC with Fedora 40.

Steps to reproduce: on a PC with Fedora or some other Linux distribution with all the necessary compiling tools installed (kernel-devel, make, git-core, gcc-aarch64-linux-gnu), give the following commands:

git clone https://github.com/jwrdegoede/rtl8189ES_linux.git
cd rtl8189ES_linux
git checkout -B rtl8189fs origin/rtl8189fs
make -j1 ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- KSRC=/usr/src/kernels/$(uname -r)

The last command produces an error output:
aarch64-linux-gnu-gcc: error: unrecognized command-line option ‘-mrecord-mcount’

The same commands on an ARM64 device compiles the driver.

To be honest, I'm not sure whether this is a problem in this product's makefile, or that of kernel-devel.

@alireza-tabatabaee
Copy link

alireza-tabatabaee commented Sep 25, 2024

I encountered this problem as well. After doing some research, I found out that for kernel versions after 6.0 it's mandatory that the version of the gcc used to compile that kernel (and its modules) be over 12. However the latest version of arm-linux-gnueabihf-gcc that I could get from apt-get was version 9.4, so it seems that you need to build your own toolchain where the version of gcc is over 12.

I used buildroot to build the kernel, so I had access to its toolchain as well and managed to successfully compile the driver with this command.
make ARCH=arm CROSS_COMPILE=~/buildroot-2024.02.6/output/host/bin/arm-buildroot-linux-uclibcgnueabihf- KSRC=~/buildroot-2024.02.6/output/build/linux-6.1.110

@atorregr
Copy link
Author

I don't think this is why I am encountering this problem, I have checked and I am using version 14:

gcc version 14.1.1 20240507 (Red Hat Cross 14.1.1-1) (GCC)

gcc-aarch64-linux-gnu-14.1.1-1.fc40.x86_64

I think that the problem might be related to the following configurations found within kernel-devel-6.8.9-300.fc40.x86_64

[atorregr@p15s /usr/src/kernels/6.8.9-300.fc40.x86_64]$ grep -B1 record-mcount Makefile
ifdef CONFIG_FTRACE_MCOUNT_USE_CC
CC_FLAGS_FTRACE += -mrecord-mcount
[atorregr@p15s /usr/src/kernels/6.8.9-300.fc40.x86_64]$ grep CONFIG_FTRACE_MCOUNT_USE_CC .config
CONFIG_FTRACE_MCOUNT_USE_CC=y
[atorregr@p15s /usr/src/kernels/6.8.9-300.fc40.x86_64]$

The .config file does not contain that definition under kernel-devel-6.9.12-200.fc40.aarch64.

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

2 participants