rtl8189ES_linux icon indicating copy to clipboard operation
rtl8189ES_linux copied to clipboard

Cannot cross-compile on an x86_64 PC

Open atorregr opened this issue 1 year ago • 2 comments

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.

atorregr avatar Sep 05 '24 08:09 atorregr

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

alireza-tabatabaee avatar Sep 25 '24 14:09 alireza-tabatabaee

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.

atorregr avatar Sep 26 '24 07:09 atorregr