I want to build a linux kernel module individually from linux kernel open source.
Source file is mm/ksm.c.
But problems happened below
make -C /usr/src/linux-headers-3.16.0-30-generic/ M=/home/wei/module modules
make[1]: Entering directory `/usr/src/linux-headers-3.16.0-30-generic'
CC [M] /home/wei/module/ksm.o
Building modules, stage 2.
MODPOST 1 modules
WARNING: "munlock_vma_page" [/home/wei/module/ksm.ko] undefined!
WARNING: "follow_page_mask" [/home/wei/module/ksm.ko] undefined!
WARNING: "page_remove_rmap" [/home/wei/module/ksm.ko] undefined!
WARNING: "mm_find_pmd" [/home/wei/module/ksm.ko] undefined!
WARNING: "__page_check_address" [/home/wei/module/ksm.ko] undefined!
WARNING: "anon_vma_interval_tree_iter_next" [/home/wei/module/ksm.ko] undefined!
WARNING: "__mmu_notifier_change_pte" [/home/wei/module/ksm.ko] undefined!
WARNING: "ptep_clear_flush" [/home/wei/module/ksm.ko] undefined!
WARNING: "page_address_in_vma" [/home/wei/module/ksm.ko] undefined!
WARNING: "alloc_pages_vma" [/home/wei/module/ksm.ko] undefined!
WARNING: "page_add_anon_rmap" [/home/wei/module/ksm.ko] undefined!
WARNING: "try_to_free_swap" [/home/wei/module/ksm.ko] undefined!
WARNING: "lru_add_drain_all" [/home/wei/module/ksm.ko] undefined!
WARNING: "linear_hugepage_index" [/home/wei/module/ksm.ko] undefined!
WARNING: "anon_vma_interval_tree_iter_first" [/home/wei/module/ksm.ko] undefined!
WARNING: "split_huge_page_to_list" [/home/wei/module/ksm.ko] undefined!
WARNING: "handle_mm_fault" [/home/wei/module/ksm.ko] undefined!
WARNING: "mlock_vma_page" [/home/wei/module/ksm.ko] undefined!
WARNING: "__put_anon_vma" [/home/wei/module/ksm.ko] undefined!
CC /home/wei/module/ksm.mod.o
LD [M] /home/wei/module/ksm.ko
make[1]: Leaving directory `/usr/src/linux-headers-3.16.0-30-generic'
I can't resolve even I insert EXPORT_SYMBOL(fun); in each header file.
How can I resolve this WARNING ?
The best way to compile parts of the kernel code as modules is to run make menuconfig and select the compilation as module. Alternatively, this can be even done by manually editing the .config file. Manually compiling the modules of parts of the kernel is discouraged, because it adds unnecessary work.
In addition, you have to know that not all parts of the kernel can be compiled as modules: the kernel core (i.e., memory management, scheduler, etc.) has not been designed to be compiled as a loadable kernel module.
Now, concerning your specific issue, you are compiling a file related to memory management. If you look at the mm/Makefile and mm/Kconfig files, you see that this file cannot be compiled as module.
Related
I am getting a make error while running omnetpp.
I have turned the clang and the lld off. The exact error is:
Creating shared library: /home/ash/omnetpp-master/out/gcc-release/src/sim/liboppsim.so
/usr/bin/ld: /usr/local/lib/libpython3.10.a(pythonrun.o): warning: relocation against _Py_UnhandledKeyboardInterrupt' in read-only section .text'
/usr/bin/ld: /usr/local/lib/libpython3.10.a(bytearrayobject.o): relocation R_X86_64_PC32 against symbol `_Py_NoneStruct' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: bad value
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile:135: /home/ash/omnetpp-master/out/gcc-release/src/sim/liboppsim.so] Error 1
make[1]: *** [Makefile:134: sim] Error 2
make: *** [Makefile:35: allmodes] Error 2
Do NOT use the omnetpp master branch. There is absolutely no guarantee that the master branch is properly working or at least compiling at any given time.
I've getting the following linking error while compiling mlpack:
[ 37%] Linking CXX shared library ../../lib/libmlpack.so
/usr/bin/ld: /usr/lib/gcc/x86_64-pc-linux-gnu/11.2.0/../../../../lib/libiberty.a(cplus-dem.o): warning: relocation against `libiberty_demanglers' in read-only section `.text'
/usr/bin/ld: /usr/lib/gcc/x86_64-pc-linux-gnu/11.2.0/../../../../lib/libiberty.a(cp-demangle.o): relocation R_X86_64_PC32 against symbol `cplus_demangle_builtin_types' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: bad value
collect2: error: ld returned 1 exit status
make[2]: *** [src/mlpack/CMakeFiles/mlpack.dir/build.make:1040: lib/libmlpack.so.3.4] Error 1
make[1]: *** [CMakeFiles/Makefile2:2106: src/mlpack/CMakeFiles/mlpack.dir/all] Error 2
make: *** [Makefile:146: all] Error 2
It seems I need to recompile libiberty.a library with -fPIC flag. How do I do that?
I found this bug report on the issue. In my case I was able to fix things by downgrading a few packages (as described in the report):
binutils 2.36.1-3
gcc 11.1.0-3
gcc-libs 11.1.0-3
gcc fortran-11.1.0-3
Ultimately this should be resolved when binutils gets updated.
I am writing a kernel module where I am using the function for_each_online_pgdat()... to iterate over all the nodes of memory and then all the zones to retrieve some data for all the zones. It is giving the warning while compiling the kernel module.
I am also getting the similar error for for_each_zone()...
root#ubuntu:/home/**/# make make -C /lib/modules/`uname -r`/build M=`pwd` modules
make[1]: Entering directory `/home/**/'
CC [M] /home/**/test.o
Building modules, stage 2.
MODPOST 1 modules
WARNING: "next_online_pgdat" [/home/**/test.ko] undefined!
WARNING: "first_online_pgdat" [/home/**/test.ko] undefined!
CC /home/**/test.mod.o
LD [M] /home/**/test.ko
make[1]: Leaving directory `/home/**/'
I was encountering the following errors when installing watir-webdriver gem via command: sudo gem install watir-webdriver. Please help.
Here are the details:
Building native extensions. This could take a while...
ERROR: Error installing watir-webdriver:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb
checking for ffi.h... no
checking for ffi.h in /usr/local/include,/usr/include/ffi... yes
checking for ffi_call() in -lffi... yes
checking for ffi_prep_closure()... yes
checking for ffi_raw_call()... no
checking for rb_thread_blocking_region()... yes
checking for rb_thread_call_with_gvl()... yes
checking for rb_thread_call_without_gvl()... yes
checking for ffi_prep_cif_var()... no
creating extconf.h
creating Makefile
make "DESTDIR="
compiling AbstractMemory.c
compiling ArrayType.c
compiling Buffer.c
compiling Call.c
Call.c:303:5: warning: implicit declaration of function 'rb_thread_call_without_gvl' is invalid in C99 [-Wimplicit-function-declaration]
rbffi_thread_blocking_region(call_blocking_function, data, (void *) -1, NULL);
^
./Thread.h:78:39: note: expanded from macro 'rbffi_thread_blocking_region'
# define rbffi_thread_blocking_region rb_thread_call_without_gvl
^
1 warning generated.
compiling ClosurePool.c
compiling DataConverter.c
DataConverter.c:43:1: warning: control may reach end of non-void function [-Wreturn-type]
}
^
1 warning generated.
compiling DynamicLibrary.c
compiling ffi.c
compiling Function.c
Function.c:479:33: warning: incompatible pointer types passing 'VALUE (void *)' to parameter of type 'void *(*)(void *)' [-Wincompatible-pointer-types]
rb_thread_call_with_gvl(callback_with_gvl, &cb);
^~~~~~~~~~~~~~~~~
Function.c:102:46: note: passing argument to parameter 'func' here
extern void *rb_thread_call_with_gvl(void *(*func)(void *), void *data1);
^
Function.c:563:9: warning: implicit declaration of function 'rb_thread_call_without_gvl' is invalid in C99 [-Wimplicit-function-declaration]
rb_thread_call_without_gvl(async_cb_wait, &w, async_cb_stop, &w);
^
Function.c:738:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
3 warnings generated.
compiling FunctionInfo.c
compiling LastError.c
compiling LongDouble.c
compiling MappedType.c
compiling MemoryPointer.c
compiling MethodHandle.c
compiling Platform.c
compiling Pointer.c
compiling Struct.c
compiling StructByReference.c
compiling StructByValue.c
compiling StructLayout.c
compiling Thread.c
compiling Type.c
compiling Types.c
compiling Variadic.c
linking shared-object ffi_c.bundle
clang: error: unknown argument: '-multiply_definedsuppress' [-Wunused-command-line-argument-hard-error-in-future]
clang: note: this will be a hard error (cannot be downgraded to a warning) in the future
make: *** [ffi_c.bundle] Error 1
Gem files will remain installed in /Library/Ruby/Gems/2.0.0/gems/ffi-1.9.3 for inspection.
Results logged to /Library/Ruby/Gems/2.0.0/gems/ffi-1.9.3/ext/ffi_c/gem_make.out
This looks like an issue with ffi gem. I see you have Ruby 2.0. Try using ffi's version 1.0.9 which should work fine in this case.
So, execute below command first before installing watir-webdriver.
sudo gem install ffi --version='1.0.9'
Or, if you're using bundle, use following
gem 'ffi', '1.0.9'
I am giving it a go at compiling lsyncd on Mac OS X (Lion) and I got a little stuck at my configure script not being able to locate my lua libraries:-
calvin$ ./configure
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... ./install-sh -c -d
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for style of include used by make... GNU
checking dependency style of gcc... gcc3
checking whether make sets $(MAKE)... (cached) yes
checking pkg-config is at least version 0.9.0... yes
checking for LUA... no
checking for LUA... no
checking for LUA... no
checking for LUA... no
configure: error: Package requirements (lua >= 5.1.3) were not met:
No package 'lua' found
Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.
Alternatively, you may set the environment variables LUA_CFLAGS
and LUA_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.
I do have lua installed via macports.
calvin$ lua -v
Lua 5.1.4 Copyright (C) 1994-2008 Lua.org, PUC-Rio
calvin$ which lua
/opt/local/bin/lua
UPDATE
I know for sure that the lua.pc file is located in:
calvin$ sudo find /opt/local -name "lua.pc"
/opt/local/lib/pkgconfig/lua.pc
and so, gone to the extent of explicitly specifying the PKG_CONFIG and PKG_CONFIG_PATH environment variables in my .bashrc file and sourcing it. Like this:
export PKG_CONFIG="/opt/local/lib/pkgconfig:$PKG_CONFIG"
export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig:$PKG_CONFIG_PATH"
What do I need to do to set the correct PKG_CONFIG_PATH environment variable so that my configure script can find lua?
UPDATE #2
So I added in
export LUA_CFLAGS="/opt/local/include"
export LUA_LIBS="/opt/local/lib"
in my .bashrc file, and with that done, I can now run ./configure --without-inotify successfully, with the following output:-
calvin$ ./configure --without-inotify
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... ./install-sh -c -d
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for style of include used by make... GNU
checking dependency style of gcc... gcc3
checking whether make sets $(MAKE)... (cached) yes
checking pkg-config is at least version 0.9.0... yes
checking for LUA... yes
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking sys/inotify.h usability... no
checking sys/inotify.h presence... no
checking for sys/inotify.h... no
compiling without inotify
configure: creating ./config.status
config.status: creating Makefile
config.status: creating config.h
config.status: config.h is unchanged
config.status: executing depfiles commands
Unfortunately, running make doesn't work as it seems that the lsyncd.h header file is unable to include lua.h.
calvin$ make
make all-am
gcc -DHAVE_CONFIG_H -I. -g -O2 -Wall /opt/local/include -MT lsyncd.o -MD -MP -MF .deps/lsyncd.Tpo -c -o lsyncd.o lsyncd.c
In file included from lsyncd.c:16:
lsyncd.h:27:17: error: lua.h: No such file or directory
In file included from lsyncd.c:16:
lsyncd.h:52: error: expected ‘)’ before ‘*’ token
lsyncd.h:55: error: expected ‘)’ before ‘*’ token
lsyncd.h:88: error: expected ‘)’ before ‘*’ token
lsyncd.h:115: error: expected ‘)’ before ‘*’ token
lsyncd.h:118: error: expected ‘;’ before ‘void’
lsyncd.h:130: error: expected ‘)’ before ‘*’ token
lsyncd.h:131: error: expected ‘;’, ‘,’ or ‘)’ before ‘void’
lsyncd.c:44:20: error: lualib.h: No such file or directory
lsyncd.c:45:21: error: lauxlib.h: No such file or directory
lsyncd.c:64:3: error: #error "need at least one notifcation system. please rerun ./configure"
lsyncd.c:175:3: warning: #warning having to use old style realpath()
lsyncd.c:337: error: expected ‘)’ before ‘*’ token
lsyncd.c:432: error: expected ‘)’ before ‘*’ token
lsyncd.c: In function ‘pipe_tidy’:
lsyncd.c:453: error: ‘struct observance’ has no member named ‘extra’
lsyncd.c: At top level:
lsyncd.c:522: error: expected ‘)’ before ‘*’ token
lsyncd.c:564: error: expected ‘)’ before ‘*’ token
lsyncd.c:565: error: expected ‘;’, ‘,’ or ‘)’ before ‘void’
lsyncd.c: In function ‘nonobserve_fd’:
lsyncd.c:650: error: ‘struct observance’ has no member named ‘tidy’
lsyncd.c: At top level:
lsyncd.c:662: error: expected ‘)’ before ‘*’ token
lsyncd.c:689: error: expected ‘)’ before ‘*’ token
lsyncd.c:730: error: expected ‘)’ before ‘*’ token
lsyncd.c:731: error: expected ‘)’ before ‘*’ token
lsyncd.c:740: error: expected ‘)’ before ‘*’ token
lsyncd.c:800: error: expected ‘)’ before ‘*’ token
lsyncd.c:821: error: expected ‘)’ before ‘*’ token
lsyncd.c:968: error: expected ‘)’ before ‘*’ token
lsyncd.c:1011: error: expected ‘)’ before ‘*’ token
lsyncd.c:1045: error: expected ‘)’ before ‘*’ token
lsyncd.c:1097: error: expected ‘)’ before ‘*’ token
lsyncd.c:1111: error: expected ‘)’ before ‘*’ token
lsyncd.c:1186: error: expected ‘)’ before ‘*’ token
lsyncd.c:1241: error: expected ‘)’ before ‘*’ token
lsyncd.c:1268: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘lsyncdlib’
lsyncd.c:1286: error: expected ‘)’ before ‘*’ token
lsyncd.c:1309: error: expected ‘)’ before ‘*’ token
lsyncd.c:1334: error: expected ‘)’ before ‘*’ token
lsyncd.c:1346: error: expected ‘)’ before ‘*’ token
lsyncd.c:1358: error: expected ‘)’ before ‘*’ token
lsyncd.c:1371: error: expected ‘)’ before ‘*’ token
lsyncd.c:1423: error: expected ‘)’ before ‘*’ token
lsyncd.c:1449: error: expected ‘)’ before ‘*’ token
lsyncd.c:1497: error: expected ‘)’ before ‘*’ token
lsyncd.c: In function ‘main1’:
lsyncd.c:1669: error: ‘lua_State’ undeclared (first use in this function)
lsyncd.c:1669: error: (Each undeclared identifier is reported only once
lsyncd.c:1669: error: for each function it appears in.)
lsyncd.c:1669: error: ‘L’ undeclared (first use in this function)
lsyncd.c:1677: warning: implicit declaration of function ‘lua_open’
lsyncd.c:1678: warning: implicit declaration of function ‘luaL_openlibs’
lsyncd.c:1683: warning: implicit declaration of function ‘lua_getglobal’
lsyncd.c:1684: warning: implicit declaration of function ‘luaL_checkstring’
lsyncd.c:1684: warning: assignment makes pointer from integer without a cast
lsyncd.c:1693: warning: implicit declaration of function ‘lua_pop’
lsyncd.c:1710: warning: implicit declaration of function ‘printlogf0’
lsyncd.c:1717: warning: implicit declaration of function ‘register_lsyncd’
lsyncd.c:1754: warning: implicit declaration of function ‘luaL_loadfile’
lsyncd.c:1755: warning: implicit declaration of function ‘lua_tostring’
lsyncd.c:1762: warning: implicit declaration of function ‘luaL_loadbuffer’
lsyncd.c:1776: warning: implicit declaration of function ‘lua_pcall’
lsyncd.c:1776: error: ‘LUA_MULTRET’ undeclared (first use in this function)
lsyncd.c:1780: warning: implicit declaration of function ‘lua_pushlightuserdata’
lsyncd.c:1782: warning: implicit declaration of function ‘lua_insert’
lsyncd.c:1784: warning: implicit declaration of function ‘lua_settable’
lsyncd.c:1784: error: ‘LUA_REGISTRYINDEX’ undeclared (first use in this function)
lsyncd.c:1789: warning: implicit declaration of function ‘lua_gettable’
lsyncd.c:1790: warning: implicit declaration of function ‘lua_pushstring’
lsyncd.c:1792: warning: implicit declaration of function ‘lua_remove’
lsyncd.c:1800: warning: assignment makes pointer from integer without a cast
lsyncd.c:1831: warning: implicit declaration of function ‘load_runner_func’
lsyncd.c:1847: warning: implicit declaration of function ‘lua_newtable’
lsyncd.c:1849: warning: implicit declaration of function ‘lua_pushnumber’
lsyncd.c:1866: warning: assignment makes pointer from integer without a cast
lsyncd.c:1930: warning: implicit declaration of function ‘lua_pushboolean’
lsyncd.c:1935: warning: implicit declaration of function ‘masterloop’
lsyncd.c:1943: error: ‘struct observance’ has no member named ‘tidy’
lsyncd.c:1965: warning: implicit declaration of function ‘lua_close’
make[1]: *** [lsyncd.o] Error 1
make: *** [all] Error 2
Any suggestions?
SOLVED IT
./configure --without-inotify --with-fsevents CFLAGS="-I /Users/calvin/xnu-1699.24.23/" LUA_CFLAGS="-I /opt/local/include" LUA_LIBS="/opt/local/lib/liblua.a"
Dependencies are:
XNU corresponding to the version of Mac OS X, http://www.opensource.apple.com/source/xnu/xnu-1699.24.23/ for my scenario
asciidoc (which I installed through macports)
some minor syntax error in lsyncd, I have sent a pull request to the lsyncd developer https://github.com/axkibe/lsyncd
and a minor change in Makefile (after Makefile is generated from configure) from
this
doc/lsyncd.1: doc/lsyncd.1.xml
xsltproc -o $# -nonet /etc/asciidoc/docbook-xsl/manpage.xsl $<
to
doc/lsyncd.1: doc/lsyncd.1.xml
xsltproc -o $# -nonet /opt/local/etc/asciidoc/docbook-xsl/manpage.xsl $<
Then run
make
And lsyncd should be successfully compiled.