I downloaded PrimeOS' kernel from https://github.com/primebook/android_kernel_common. I just need to replace a single .c file in /drivers/platform/x86. Here's what I tried doing:-
Replaced .c
make clean && make mrproper
Copied arch//configs/android-x86_deconfig to linux source root folder as .config
fakeroot make kernel -j4
The command runs but stops abruptly and the terminal shows the $ localhost as if the task is finished. Can you tell me where I went wrong.
Update
Here's the place where the issue comes:-
HOSTCC scripts/basic/fixdep
HOSTCC scripts/kconfig/conf.o
YACC scripts/kconfig/zconf.tab.c
LEX scripts/kconfig/zconf.lex.c
..............................................................
CC kernel/time/timeconv.o
In file included from ./arch/x86/include/asm/string.h:3,
from ./include/linux/string.h:20,
from ./arch/x86/include/asm/page_32.h:35,
from ./arch/x86/include/asm/page.h:14,
from ./arch/x86/include/asm/thread_info.h:12,
from ./include/linux/thread_info.h:38,
from ./arch/x86/include/asm/preempt.h:7,
from ./include/linux/preempt.h:81,
from ./include/linux/spinlock.h:51,
from ./include/linux/mmzone.h:8,
from ./include/linux/gfp.h:6,
from ./include/linux/mm.h:10,
from ./include/linux/ring_buffer.h:5,
from kernel/trace/trace.c:15:
In function ‘ftrace_dump’,
inlined from ‘ftrace_dump’ at kernel/trace/trace.c:8269:6:
./arch/x86/include/asm/string_32.h:325:29: warning: ‘__builtin_memset’ offset [8297, 8336] from the object at ‘iter’ is out of the bounds of referenced subobject ‘seq’ with type ‘struct trace_seq’ at offset 4176 [-Warray-bounds]
325 | #define memset(s, c, count) __builtin_memset(s, c, count)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
kernel/trace/trace.c:8347:3: note: in expansion of macro ‘memset’
8347 | memset(&iter.seq, 0,
| ^~~~~~
CC kernel/time/timecounter.o
..............................................................
AR kernel/built-in.a
$
Full Log: https://pastebin.com/8T3G3Uyc
So, it just comes back to $ as if the process completed at kernel/built-in.a. This is the file where every time it stops. Even if I compile the kernel without any changes, it still stops at kernel/built-in.a
BTW, I am just using the source I downloaded from primebook and installed the necessary packages for recompiling the kernel. Should I be doing something else too.
UPDATE 1
I tried running make -j4 bzImage modules but this again stops at
AR drivers/video/built-in.a
AR drivers/built-in.a
Even this doesn't compile a bzImage
UPDATE 2
I tried running make kernel on a Linux source (5.4.0) and even that stops at built-in.a
UPDATE 3
I tried running make bzImage modules without -j4 and I get a new error now
sound/soc/codecs/es8316.c:766:1: note: in expansion of macro ‘module_i2c_driver’
766 | module_i2c_driver(es8316_i2c_driver);
| ^~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors
make[3]: *** [scripts/Makefile.build:304: sound/soc/codecs/es8316.o] Error 1
make[2]: *** [scripts/Makefile.build:544: sound/soc/codecs] Error 2
make[1]: *** [scripts/Makefile.build:544: sound/soc] Error 2
make: *** [Makefile:1050: sound] Error 2
Full log: https://pastebin.com/JJeh4QTk
UPDATE 4
make bzImageworks and outputs the bzImage as expected.
Fix for kernel compilation stopping at make a built-in.a file
Use make bzImage or make bzImage modules instead of make kernel
Update - In my case the error was with the ES8316.c which was causing the compilation to stop. Go to your config file and delete the lines pertaining to ES8316 and the build went through successfully.
Fix for other Errors in the question
For the codec issue and for any other conflicting module, go to your config file and search for it, for eg:- i had issue with the module for ES8316. To fix it, remove the line corresponding to ES8316 in your config file or add a # infront of it. You may also try to debug the problem if you really need that driver.
Other things that you could try
I had gcc-9 installed and installing gcc-8 did help at times.
Related
I am trying to compile my kernel module using the Yocto SDK I generated via bitbake.
The SDK builds without issue, but when I try to run make scripts ARCH=arm64 in the kernel source directory of my target's sysroot, I get an issue regarding a missing header file:
...
HOSTCC scripts/conmakehash
HOSTCC scripts/sortextable
HOSTCC scripts/asn1_compiler
HOSTCC scripts/extract-cert
scripts/extract-cert.c:21:10: fatal error: openssl/bio.h: No such file or directory
21 | #include <openssl/bio.h>
| ^~~~~~~~~~~~~~~
compilation terminated.
make[1]: *** [scripts/Makefile.host:107: scripts/extract-cert] Error 1
make: *** [Makefile:1096: scripts] Error 2
I have TOOLCHAIN_TARGET_TASK_append = " kernel-devsrc openssl-dev alsa-dev" in my image .bb file, which I believe should provide the missing openssl/bio.h file, but this does not seem to be the case.
The only way I have been able to solve this issue is to install libssl-dev on my SDK machine, but this feels like a workaround, and not the proper solution. My expectation is that when you source the environment from the SDK, it should provide the necessary headers for the kernel.
Since scripts/extract-cert.c is compiled for the host environment, I'd rather try appending TOOLCHAIN_HOST_TASK variable with " openssl-dev ".
See this question: TOOLCHAIN_HOST_TASK Vs TOOLCHAIN_TARGET_TASK
I have been trying for hours to recompile Linux kernel of https://github.com/torvalds/linux from my MacBook Pro and at the end, still stuck. Hard to find a tutorial to understand how to recompile it, headers missing, bla bla bla.
http://www.howardism.org/Technical/Linux/Rebuilding_Kernel.html
https://medium.com/#ssreehari/implementing-a-system-call-in-linux-kernel-4-7-1-6f98250a8c38
https://tssurya.wordpress.com/2014/08/19/adding-a-hello-world-system-call-to-linux-kernel-3-16-0/ (but useless since I have the v4.17)
PS: I tried first adding a syscall website because that's what I'm trying to do at first.
At the begining, I got a .config not found.
*** Configuration file ".config" not found!
***
*** Please run some configurator (e.g. "make oldconfig" or
*** "make menuconfig" or "make xconfig").
***
make[3]: *** [silentoldconfig] Error 1
make[2]: *** [silentoldconfig] Error 2
make[1]: *** No rule to make target `include/config/auto.conf', needed by`include/config/kernel.release'. Stop.
Unlike in some web-links, the conf used doesn't exist or something else is wrong, so I'm creating a new .config from "make menuconfig" (as some answers on the web).
Then, I try to compile again. There is some command I tried:
- make
emixam23#Maximes-MBP:~/Workspace/linux-kernel$ make
getconf: no such configuration parameter `LFS_CFLAGS'
getconf: no such configuration parameter `LFS_LDFLAGS'
getconf: no such configuration parameter `LFS_LIBS'
/bin/sh: scripts/basic/modules.order: Permission denied
make[1]: *** [scripts/basic/modules.order] Error 1
make: *** [scripts_basic] Error 2
- sudo make
emixam23#Maximes-MBP:~/Workspace/linux-kernel$ sudo make
Password:
getconf: no such configuration parameter `LFS_CFLAGS'
getconf: no such configuration parameter `LFS_LDFLAGS'
getconf: no such configuration parameter `LFS_LIBS'
HOSTCC arch/x86/tools/relocs_32.o
In file included from arch/x86/tools/relocs_32.c:2:
arch/x86/tools/relocs.h:13:10: fatal error: 'elf.h' file not found
#include <elf.h>
^~~~~~~
1 error generated.
make[1]: *** [arch/x86/tools/relocs_32.o] Error 1
make: *** [archscripts] Error 2
After that, I begin to search if the mistake was coming from my make command and I found this:
- sudo make -j 4 && sudo make modules_install -j 4 && sudo make install -j 4
emixam23#Maximes-MBP:~/Workspace/linux-kernel$ sudo make -j 4 && sudo make modules_install -j 4 && sudo make install -j 4
getconf: no such configuration parameter `LFS_CFLAGS'
getconf: no such configuration parameter `LFS_LDFLAGS'
getconf: no such configuration parameter `LFS_LIBS'
CHK include/config/kernel.release
CHK include/generated/uapi/linux/version.h
CHK include/generated/utsrelease.h
HOSTCC arch/x86/tools/relocs_32.o
HOSTCC arch/x86/tools/relocs_64.o
HOSTCC arch/x86/tools/relocs_common.o
In file included from arch/x86/tools/relocs_common.c:2:
arch/x86/tools/relocs.h:13:10: fatal error: 'elf.h' file not found
#include <elf.h>
^~~~~~~
In file included from arch/x86/tools/relocs_32.c:2:
arch/x86/tools/relocs.h:13:10: fatal error: 'elf.h' file not found
#include <elf.h>
^~~~~~~
In file included from arch/x86/tools/relocs_64.c:2:
arch/x86/tools/relocs.h:13:10: fatal error: 'elf.h' file not found
#include <elf.h>
^~~~~~~
1 error generated.
make[1]: *** [arch/x86/tools/relocs_common.o] Error 1
make[1]: *** Waiting for unfinished jobs....
1 error generated.
1 error generated.
make[1]: *** [arch/x86/tools/relocs_32.o] Error 1
make[1]: *** [arch/x86/tools/relocs_64.o] Error 1
make: *** [archscripts] Error 2
make: INTERNAL: Exiting with 5 jobserver tokens available; should be 4!
So, based on the errors I got, I searched about <elf.h> and it seems to be something about Android. To me, it doesn't have any links, I mean, I feel like this.
The thing is, I just downloaded a Linux kernel (Torvalds), I added my syscall, now I'm trying to recompile it and use it with vagrant. That's it. Why does it seem so complicated? I will be honest, I feel completely lost... Do you have any idea if I'm right but I just missunderstood something, or I'm totally out of the good way?
I am working from a MacBook Pro:
MacBook Pro (Retina, 15-inch, Mid 2015)
macOS High Sierra
Version 10.13.1
Thanks for any hints/help
Max
PS: Edit 1: Add of my edits: https://github.com/Emixam23/linux-kernel/commit/d7d7b66cc6513e7b69fd2122b880c259628c438a
Vagrant
I found a workaround which is vagrant :) With vragrant you can recompile the kernel from a Mac OS. You just have to vagrant init then you connect yourself to the vagrant VM vagrant ssh. Once your inside the vagrant VM, run cd / and you will arrive to the root of your machin, which is also where you created the VM, so you can do whatever you want from Mac OS and compile from the terminal make -j 4 :)
Check your tool-chain. It is not just android thing. https://linux.die.net/man/5/elf.
Please go ahead if you like being challenged. cause this will not be straight forward.
If your task is just compiling code use virtual machine / other linux machine it will be quicker.
But if you are curious to check how things work and getting them work on mac for future compilations without vm. then continue.try adding those header files. in /usr/include as per this
I am new to compiling.
I am trying to compile iperf3 for Windows 10 because there is no official Windows distribution of iperf3 and for the learning experience. I am trying to do so on the new Windows Subsystem for Linux feature via Bash on Ubuntu on Windows, also for the learning experience.
I installed mingw-w64, which should give me the proper compiler and environment necessary for cross-compiling:
sudo apt-get install mingw-w64
This put two directories into my /usr directory:
i686-w64-mingw32
x86_64-w64-mingw32
It also put a bunch of things that look like compilers into /usr/bin.
I unzipped the .tar.gz file from iperf3 and navigated into it. Then, I run ./configure --host=i686-w64-mingw32.static and it completes without errors.
I note that the output of the command has a worrisome line: checking for i686-w64-mingw32.static-gcc... no
I note that the Makefile's CC variable is set to gcc, which doesn't sound like the proper compiler.
Then, I run make. It fails with errors:
collect2: error: ld returned 1 exit status
make[2]: *** [iperf3] Error 1
make[2]: Leaving directory `/home/snip/iperf3/iperf-3.1.4/src'
make[1]: *** [all] Error 2
make[1]: Leaving directory `/home/snip/iperf3/iperf-3.1.4/src'
make: *** [all-recursive] Error 1
I also see the line: libtool: warning: undefined symbols not allowed in i686-w64-mingw32.static shared libraries; building static only
I think that the ./configure is not working correctly since it appears to have not found the right compiler for my --host argument and put it in the Makefile.
What am I doing wrong?
EDIT:
I changed the command to ./configure --host=i686-w64-mingw32 per comments and it completes without error. But no makefile is created so make yields make: *** No targets specified and no makefile found. Stop.
What am I doing wrong, now?
EDIT 2:
Looks like the ./configure actually is failing. Last line of its output is nanosleep() required for timing operations., which seems to mean that its missing a library for nanosleep.
How do I get nanosleep?
mingw doesn't support nanosleep. So programs using it cannot be compiled using mingw-w64.
I was compiling a source code, and it always fails at make command, below is the error message.
gcc: unrecognized option '-rdynamic'
/usr/lib/gcc/i686-pc-cygwin/4.5.3/../../../../i686-pc-cygwin/bin/ld: \
warning: --export-dynamic is not supported for PE targets, \
did you mean --export-all-symbols?
/usr/lib/gcc/i686-pc-cygwin/4.5.3/../../../../i686-pc-cygwin/bin/ld: \
warning: --export-dynamic is not supported for PE targets, \
did you mean --export-all-symbols?
make[3]: Leaving directory `/home/alimjan/slim502/src'
make[2]: Leaving directory `/home/alimjan/slim502/src'
make[1]: Leaving directory `/home/alimjan/slim502/src'
Making all in lib
make[1]: Entering directory `/home/alimjan/slim502/lib'
Cannot execute /bin/lmntal
Makefile:422: recipe for target `config.il' failed
make[1]: *** [config.il] Error 1
make[1]: Leaving directory `/home/alimjan/slim502/lib'
Makefile:293: recipe for target `all-recursive' failed
make: *** [all-recursive] Error 1
(Above lines broken to display)
I could not solve this. I am new to make and don't know what to do?
Usually when a makefile output looks as severe as your output, then it is because of the environment of which it is being used on has changed -- it could perhaps be that some external files have been moved or deleted or it could be that the make is too big, especially if the make is recursive in nature ( stay away from recursive makefiles; go NR)
Anyway if I where you I would look into where the environment had changed -- perhaps if your project is in a version system - try a different branch
Trying to solve the problems in the makefile could be very difficult and so it is better to go back to a version that worked and then move on from there
I'm not really sure this is a problem with the makefile. The error is:
Cannot execute /bin/lmntal
I'm fairly sure if you tried to run "/bin/lmntal" yourself from the command line you'd get a similar error. It seems that your build requires some extra utility in order to run, that you don't have or which isn't working on your system. Does that file (/bin/lmntal) exist? Is it executable? Is it a script and if so, does the first line refer to an interpreter that exists and is executable? Is it a 32bit program (use file /bin/lmntal) while you're using a 64bit operating system and if so, do you have the 32bit versions of libc, etc. installed on your Ubuntu system? Or vice versa (if you have a 32bit Ubuntu and the utility is a 64bit program you won't be able to run it at all)?
Alternatively it could be that this program is supposed to be found somewhere else or named something else, and your makefile is at fault because some variables are not set; for example the makefile could say something like $(FOODIR)/bin/lmntal and for some reason the variable $(FOODIR) is not set.
If you provide the details above (file exists? Permissions? file output? Complete rule at line 422 of the makefile?) we can provide more help.
I'm trying to test this script from oracle to get active NFS clients on Ubuntu 10.04, but I can' get it to run.
To achieve that, I first installed dtrace following these instructions. This is what I've done exactly:
apt-get install bison flex zlib1g-dev libelf-dev binutils-dev libdw-dev libc6-dev-i386
wget ftp://crisp.dyndns-server.com/pub/release/website/dtrace/dtrace-20121009.tar.bz2
tar xfj dtrace-20121009.tar.bz2
cd dtrace-20121009
make all
make install
make load
However, I get this warning when compiling:
=================================================================
=== You need /usr/lib/libdwarf.a and /usr/lib/libbfd.a installed to build.
===
=== apt-get install binutils-dev
=== apt-get install libdw-dev
===
=== Without these, we will not build ctfconvert (needed for
=== SDT structure definitions).
=================================================================
cd cmd/instr ; make --no-print-directory
cd usdt/c ; make --no-print-directory
tools/mkdriver.pl all
Executing: /usr/src/dtrace/dtrace-20121009/tools/make-me
make -C /lib/modules/2.6.38-16-server/build M=/usr/src/dtrace/dtrace-20121009/build-2.6.38-16-server/driver
CC [M] /usr/src/dtrace/dtrace-20121009/build-2.6.38-16-server/driver/systrace.o
LD [M] /usr/src/dtrace/dtrace-20121009/build-2.6.38-16-server/driver/dtracedrv.o
Building modules, stage 2.
MODPOST 1 modules
LD [M] /usr/src/dtrace/dtrace-20121009/build-2.6.38-16-server/driver/dtracedrv.ko
tools/mkctf.sh
build/ctfconvert not available - so not building the linux.ctf file
NOTE: The build is complete, but build/ctfconvert is not available.
This means you will get run time errors from the io.d and sched.d files
due to undefined kernel structure definitions. Simply delete or rename
these files until a fix can be put in place to handle older
distros which do not have the required libdwarf dependencies.
(Typical error is references to undefined struct definitions such
as dtrace_cpu_t).
sync
I've installed libdw-dev and binutils-dev, but taking a look at the makefile, it seems it looks for libdwarf.so, and libdw on my system is named libdw.so.
To circunvent this, I create a symlink with ln -s /usr/lib/libdw.so /usr/lib/libdwarf.so. After doing so, compiling fails.
cd cmd/ctfconvert ; make --no-print-directory
gcc -g -I. -I../../ -I../../libctf -I../../common -I../../uts/common -I../../linux -I/usr/include/libdwarf -c dwarf.c
In file included from dwarf.c:94:
/usr/include/dwarf.h:56: error: expected identifier before numeric constant
/usr/include/dwarf.h:136: error: expected identifier before numeric constant
/usr/include/dwarf.h:321: error: expected identifier before numeric constant
/usr/include/dwarf.h:461: error: expected identifier before numeric constant
/usr/include/dwarf.h:517: error: expected identifier before numeric constant
make[3]: *** [../../build/ctfconvert.obj/dwarf.o] Error 1
make[2]: *** [all] Error 2
make[1]: *** [do_cmds] Error 2
tools/bug.sh
make: *** [all] Error 1
So, let's undo that. I remove the symlink, compile again, run make install and make load and hope everything is fine. And everything seems to be fine.
But, then I try to run the script mentioned above, and it fails:
# ./get_ngs_clients.d
dtrace: failed to compile script ./get_ngs_clients.d: Preprocessor not found
I have no clue on what's going on. I have gcc installed, just in case.
# dpkg -l | grep gcc
ii gcc 4:4.4.3-1ubuntu1 The GNU C compiler
ii gcc-4.4 4.4.3-4ubuntu5.1 The GNU C compiler
ii gcc-4.4-base 4.4.3-4ubuntu5.1 The GNU Compiler Collection (base package)
ii gcc-4.4-multilib 4.4.3-4ubuntu5.1 The GNU C compiler (multilib files)
ii gcc-multilib 4:4.4.3-1ubuntu1 The GNU C compiler (multilib files)
ii lib32gcc1 1:4.4.3-4ubuntu5.1 GCC support library (32 bit Version)
ii libgcc1 1:4.4.3-4ubuntu5.1 GCC support library
If you do not have libdwarf.a on your system, the ctfconvert tool will not build. (libdwarf.a and libdw.a are not the same).
If ctfconvert does not build, then any of your own, or the dtrace etc/*.d scripts may not load. (Dtrace force loads these scripts for you automatically, which is annoying). Any script which relies on structure definitions will then fail.
As of May 2013, I am looking at seeing what it takes to update to libdw.a since this seems to be the modern replacement for libdwarf.
(posted by the 'author' of DTrace/Linux).
Have you tried to add --enable-dtrace=false to /.configure?
Or maybe --with-dtrace=false?
That should do the trick I think...