Hi Alan, On Sun, Jul 22, 2018 at 09:01:59PM +0200, Alan Keane wrote: > Hi Himanshu, > > >> > Hi, > > > I am currently working on my GSoC project and while testing through > 0-day test service, I hit the following error: > > drivers/iio/chemical/bme680_core.o: In function `bme680_compensate_gas': > drivers/iio/chemical/bme680_core.c:450: undefined reference to `__divdi3' > > << > > Are these errors that stop compilation or the compiler "just" giving > warnings? https://lists.01.org/pipermail/kbuild-all/2018-July/050481.html > I'm guessing they are warnings because you have an object file that you can > disassemble to find the idiv instruction? Not sure to understand the question!? > Are you building this code within the linux build system, I ask because I > work a lot on bare metal systems and see a lot of these kind of warnings, > on bare metal systems sometimes you have to implement __divdi3 (and > friends) yourself, if your code does build (with warnings) does it link and > most importantly does it (at least appear to) work? Yes, I'm building within my linux machine. The thing is when you do 64bit arithmetic operations in the code for an architecture where there is no support for such operations(i386) For instance in my code: 64 bit division calc_gas_res = (u32) ((var3 + ((s64) var2 >> 1)) / (s64) var2); In such situations, gcc provides its own runtime library(libgcc.a or libgcc_s.so.1) to perform those operations: Runtime Function: long __divdi3 (long a, long b) But the linker in the kernel compilation doesn't link libgcc and therefore, we get this error. To solve the problem we can do: 1. Use do_div() (look math64.h for more functions) to prevent build error on 32bit environments. 2. Link statically libgcc using flags: -static-libgcc -lgcc I have not cross-compiled for i386 and checked, but looking at kbuild report it likely that build terminates and no linking takes place. So, I need to use option 1. and test. I'm sure div64_s64() would solve my problem. Also, please avoid top-posting :) -- Himanshu Jha Undergraduate Student Department of Electronics & Communication Guru Tegh Bahadur Institute of Technology _______________________________________________ Kernelnewbies mailing list Kernelnewbies@xxxxxxxxxxxxxxxxx https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies