All of lore.kernel.org
 help / color / mirror / Atom feed
* [Xenomai] Issues building old drivers under Xenomai 3.0.5
@ 2017-08-30  1:17 Jim Langston
  2017-08-30  2:38 ` [Xenomai] Two Minor Issues with Patches Stephen D. Cohen
  2017-08-30  7:20 ` [Xenomai] Issues building old drivers under Xenomai 3.0.5 Philippe Gerum
  0 siblings, 2 replies; 10+ messages in thread
From: Jim Langston @ 2017-08-30  1:17 UTC (permalink / raw)
  To: xenomai

Hi all,

I'm having trouble getting an old driver originally built for Xenomai 2.4
to build under Xenomai 3.0.5.  The code won't build under Ubuntu 16.04
patched with Xenomai 3.0.5 and kernel 4.9.24 and the IPipe patch for 4.9.24.

The problem seems to revolve around include pathing, and the simplest case
I can put together is as follows:

------------------
Makefile
------------------
XENOCONFIG:=/usr/xenomai/bin/xeno-config
KDIR ?= /lib/modules/`uname -r`/build
INCLUDEDIR    :=/usr/include
PWD        := $(shell pwd)
$(eval ccflags-y = -v $(shell $(XENOCONFIG) --native --rtdm --compat
--cflags))

ifneq ($(KERNELRELEASE),)
obj-m        := rfidrv2.o
else
rfidrv    : rfidrv2.c
    $(MAKE) -C $(KDIR) M=$(PWD) SUBDIRS=$(PWD) modules
endif

------------------
rfidrv2.c
------------------
#include <native/heap.h>
// Yes, just the one include line -- I removed all the rest of the code
===============================================

Output:

make -C /lib/modules/`uname -r`/build M=/home/jlangston/mi/rfidrv/rfidrv
SUBDIRS=/home/jlangston/mi/rfidrv/rfidrv modules
make[1]: Entering directory '/usr/src/linux-4.9.24'
  CC [M]  /home/jlangston/mi/rfidrv/rfidrv/rfidrv2.o
Using built-in specs.
COLLECT_GCC=gcc
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
5.4.0-6ubuntu1~16.04.4'
--with-bugurl=file:///usr/share/doc/gcc-5/README.Bugs
--enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr
--program-suffix=-5 --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=new --enable-gnu-unique-object
--disable-vtable-verify --enable-libmpx --enable-plugin --with-system-zlib
--disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo
--with-java-home=/usr/lib/jvm/java-1.5.0-gcj-5-amd64/jre --enable-java-home
--with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-5-amd64
--with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-5-amd64
--with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar
--enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686
--with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib
--with-tune=generic --enable-checking=release --build=x86_64-linux-gnu
--host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.4)
COLLECT_GCC_OPTIONS='-nostdinc' '-isystem'
'/usr/lib/gcc/x86_64-linux-gnu/5/include' '-I' './arch/x86/include' '-I'
'./arch/x86/include/generated/uapi' '-I' './arch/x86/include/generated'
'-I' './include' '-I' './arch/x86/include/uapi' '-I' './include/uapi' '-I'
'./include/generated/uapi' '-include' './include/linux/kconfig.h' '-D'
'__KERNEL__' '-Wall' '-Wundef' '-Wstrict-prototypes' '-Wno-trigraphs'
'-fno-strict-aliasing' '-fno-common'
'-Werror=implicit-function-declaration' '-Wno-format-security' '-std=gnu90'
'-fno-PIE' '-mno-sse' '-mno-mmx' '-mno-sse2' '-mno-3dnow' '-mno-avx' '-m64'
'-falign-jumps=1' '-falign-loops=1' '-mno-80387' '-mno-fp-ret-in-387'
'-mpreferred-stack-boundary=3' '-mskip-rax-setup' '-mtune=generic'
'-mno-red-zone' '-mcmodel=kernel' '-funit-at-a-time'
'-maccumulate-outgoing-args' '-D' 'CONFIG_X86_X32_ABI' '-D'
'CONFIG_AS_CFI=1' '-D' 'CONFIG_AS_CFI_SIGNAL_FRAME=1' '-D'
'CONFIG_AS_CFI_SECTIONS=1' '-D' 'CONFIG_AS_FXSAVEQ=1' '-D'
'CONFIG_AS_SSSE3=1' '-D' 'CONFIG_AS_CRC32=1' '-D' 'CONFIG_AS_AVX=1' '-D'
'CONFIG_AS_AVX2=1' '-D' 'CONFIG_AS_AVX512=1' '-D' 'CONFIG_AS_SHA1_NI=1'
'-D' 'CONFIG_AS_SHA256_NI=1' '-pipe' '-Wno-sign-compare'
'-fno-asynchronous-unwind-tables' '-I' 'arch/x86/xenomai/include' '-I'
'include/xenomai' '-fno-delete-null-pointer-checks' '-O2' '--param'
'allow-store-data-races=0' '-Wframe-larger-than=1024'
'-fstack-protector-strong' '-Wno-unused-but-set-variable'
'-fno-omit-frame-pointer' '-fno-optimize-sibling-calls'
'-fno-var-tracking-assignments' '-g' '-gdwarf-4' '-pg' '-mfentry' '-D'
'CC_USING_FENTRY' '-Wdeclaration-after-statement' '-Wno-pointer-sign'
'-fno-strict-overflow' '-fconserve-stack' '-Werror=implicit-int'
'-Werror=strict-prototypes' '-Werror=date-time'
'-Werror=incompatible-pointer-types' '-D' 'CC_HAVE_ASM_GOTO' '-v' '-I'
'/usr/xenomai/include/trank/posix' '-I' '/usr/xenomai/include/trank' '-D'
'__XENO_COMPAT__' '-I' '/usr/xenomai/include/cobalt' '-I'
'/usr/xenomai/include' '-D' '_GNU_SOURCE' '-D' '_REENTRANT' '-D'
'__COBALT__' '-I' '/usr/xenomai/include/alchemy' '-D' '__COBALT_WRAP__'
'-D' 'MODULE' '-D' 'KBUILD_BASENAME="rfidrv2"' '-D'
'KBUILD_MODNAME="rfidrv2"' '-c' '-o'
'/home/jlangston/mi/rfidrv/rfidrv/.tmp_rfidrv2.o' '-march=x86-64'
 /usr/lib/gcc/x86_64-linux-gnu/5/cc1 -quiet -nostdinc -v -I
./arch/x86/include -I ./arch/x86/include/generated/uapi -I
./arch/x86/include/generated -I ./include -I ./arch/x86/include/uapi -I
./include/uapi -I ./include/generated/uapi -I arch/x86/xenomai/include -I
include/xenomai -I /usr/xenomai/include/trank/posix -I
/usr/xenomai/include/trank -I /usr/xenomai/include/cobalt -I
/usr/xenomai/include -I /usr/xenomai/include/alchemy -imultiarch
x86_64-linux-gnu -D __KERNEL__ -D CONFIG_X86_X32_ABI -D CONFIG_AS_CFI=1 -D
CONFIG_AS_CFI_SIGNAL_FRAME=1 -D CONFIG_AS_CFI_SECTIONS=1 -D
CONFIG_AS_FXSAVEQ=1 -D CONFIG_AS_SSSE3=1 -D CONFIG_AS_CRC32=1 -D
CONFIG_AS_AVX=1 -D CONFIG_AS_AVX2=1 -D CONFIG_AS_AVX512=1 -D
CONFIG_AS_SHA1_NI=1 -D CONFIG_AS_SHA256_NI=1 -D CC_USING_FENTRY -D
CC_HAVE_ASM_GOTO -D __XENO_COMPAT__ -D _GNU_SOURCE -D _REENTRANT -D
__COBALT__ -D __COBALT_WRAP__ -D MODULE -D KBUILD_BASENAME="rfidrv2" -D
KBUILD_MODNAME="rfidrv2" -isystem /usr/lib/gcc/x86_64-linux-gnu/5/include
-include ./include/linux/kconfig.h -MD
/home/jlangston/mi/rfidrv/rfidrv/.rfidrv2.o.d
/home/jlangston/mi/rfidrv/rfidrv/rfidrv2.c -quiet -dumpbase rfidrv2.c
-mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -m64 -mno-80387
-mno-fp-ret-in-387 -mpreferred-stack-boundary=3 -mskip-rax-setup
-mtune=generic -mno-red-zone -mcmodel=kernel -maccumulate-outgoing-args
-mfentry -march=x86-64 -auxbase-strip
/home/jlangston/mi/rfidrv/rfidrv/.tmp_rfidrv2.o -g -gdwarf-4 -O2 -Wall
-Wundef -Wstrict-prototypes -Wno-trigraphs
-Werror=implicit-function-declaration -Wno-format-security
-Wno-sign-compare -Wframe-larger-than=1024 -Wno-unused-but-set-variable
-Wdeclaration-after-statement -Wno-pointer-sign -Werror=implicit-int
-Werror=strict-prototypes -Werror=date-time
-Werror=incompatible-pointer-types -std=gnu90 -version -p
-fno-strict-aliasing -fno-common -fno-PIE -falign-jumps=1 -falign-loops=1
-funit-at-a-time -fno-asynchronous-unwind-tables
-fno-delete-null-pointer-checks -fstack-protector-strong
-fno-omit-frame-pointer -fno-optimize-sibling-calls
-fno-var-tracking-assignments -fno-strict-overflow -fconserve-stack --param
allow-store-data-races=0 -fstack-protector-strong -o - |
 as -v -I ./arch/x86/include -I ./arch/x86/include/generated/uapi -I
./arch/x86/include/generated -I ./include -I ./arch/x86/include/uapi -I
./include/uapi -I ./include/generated/uapi -I arch/x86/xenomai/include -I
include/xenomai -I /usr/xenomai/include/trank/posix -I
/usr/xenomai/include/trank -I /usr/xenomai/include/cobalt -I
/usr/xenomai/include -I /usr/xenomai/include/alchemy --64 -o
/home/jlangston/mi/rfidrv/rfidrv/.tmp_rfidrv2.o
GNU assembler version 2.26.1 (x86_64-linux-gnu) using BFD version (GNU
Binutils for Ubuntu) 2.26.1
GNU C89 (Ubuntu 5.4.0-6ubuntu1~16.04.4) version 5.4.0 20160609
(x86_64-linux-gnu)
    compiled by GNU C version 5.4.0 20160609, GMP version 6.1.0, MPFR
version 3.1.4, MPC version 1.0.3
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
#include "..." search starts here:
#include <...> search starts here:
 ./arch/x86/include
 ./arch/x86/include/generated/uapi
 ./arch/x86/include/generated
 ./include
 ./arch/x86/include/uapi
 ./include/uapi
 ./include/generated/uapi
 arch/x86/xenomai/include
 include/xenomai
 /usr/xenomai/include/trank/posix
 /usr/xenomai/include/trank
 /usr/xenomai/include/cobalt
 /usr/xenomai/include
 /usr/xenomai/include/alchemy
 /usr/lib/gcc/x86_64-linux-gnu/5/include
End of search list.
GNU C89 (Ubuntu 5.4.0-6ubuntu1~16.04.4) version 5.4.0 20160609
(x86_64-linux-gnu)
    compiled by GNU C version 5.4.0 20160609, GMP version 6.1.0, MPFR
version 3.1.4, MPC version 1.0.3
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 78b6f8b2ed219a71c67c16db887e4800
In file included from /usr/xenomai/include/alchemy/heap.h:21:0,
                 from /usr/xenomai/include/trank/native/heap.h:21,
                 from /home/jlangston/mi/rfidrv/rfidrv/rfidrv2.c:2:
/usr/lib/gcc/x86_64-linux-gnu/5/include/stdint.h:9:26: error: no include
path in which to search for stdint.h
In file included from /usr/xenomai/include/trank/posix/pthread.h:19:0,
                 from /usr/xenomai/include/copperplate/clockobj.h:22,
                 from /usr/xenomai/include/alchemy/timer.h:22,
                 from /usr/xenomai/include/alchemy/heap.h:22,
                 from /usr/xenomai/include/trank/native/heap.h:21,
                 from /home/jlangston/mi/rfidrv/rfidrv/rfidrv2.c:2:
/usr/xenomai/include/cobalt/pthread.h:19:26: fatal error: pthread.h: No
such file or directory
compilation terminated.
scripts/Makefile.build:299: recipe for target
'/home/jlangston/mi/rfidrv/rfidrv/rfidrv2.o' failed
make[2]: *** [/home/jlangston/mi/rfidrv/rfidrv/rfidrv2.o] Error 1
Makefile:1490: recipe for target '_module_/home/jlangston/mi/rfidrv/rfidrv'
failed
make[1]: *** [_module_/home/jlangston/mi/rfidrv/rfidrv] Error 2
make[1]: Leaving directory '/usr/src/linux-4.9.24'
Makefile:11: recipe for target 'rfidrv' failed
make: *** [rfidrv] Error 2

Does anyone have a driver that they could post up that uses the heap
functions, a sample 'Makefile' with different flags/include options, or any
suggestions on how to resolve the include file mess here?

Thanks,
Jim

^ permalink raw reply	[flat|nested] 10+ messages in thread
* [Xenomai] Two Minor Issues, With Patches
@ 2017-08-30 20:51 Stephen D. Cohen
  0 siblings, 0 replies; 10+ messages in thread
From: Stephen D. Cohen @ 2017-08-30 20:51 UTC (permalink / raw)
  To: xenomai

Dear Xenomai Team,

I have run into a couple of issues recently and have finally gotten around
to reporting them with my associated patches to correct them. These may be
of interest to others so I am posting them to the list. I am pretty sure
this is the correct way to submit them anyway.

The first issue is with debug backtrace handler and slackspot. The
backtrace handler in the kernel code is removing the virtual-memory offset
from all backtrace PCs regardless of origin. This is not appropriate for
executable files, and so addr2line (and thus slackspot) cannot report the
line numbers for these spots.

The simple solution is to check the backtrace section to see if it is from
an executable file and act accordingly. Here is the patch:

----- Start Patch -----
--- a/xenomai-3.0.5/kernel/cobalt/debug.c
+++ b/xenomai-3.0.5/kernel/cobalt/debug.c
@@ -23,6 +23,7 @@
 #include <linux/mm.h>
 #include <linux/signal.h>
 #include <linux/vmalloc.h>
+#include <linux/elf.h>
 #include <cobalt/kernel/sched.h>
 #include <cobalt/kernel/heap.h>
 #include <cobalt/kernel/clock.h>
@@ -246,7 +247,11 @@
  if (vma == NULL)
  continue;

- spot.backtrace[depth].pc = pc - vma->vm_start;
+ if (!memcmp((u8 *)vma->vm_start, ELFMAG, SELFMAG) &&
+     ((struct elfhdr *)vma->vm_start)->e_type == ET_EXEC)
+ spot.backtrace[depth].pc = pc;
+ else
+ spot.backtrace[depth].pc = pc - vma->vm_start;


  /*
  * Even in case we can't fetch the map name, we still
----- End Patch -----

One caveat - this issue does not appear to show up in the example on the
web page describing slackspot, and I am at a loss to explain how that can
be. Perhaps the ARM backtrace routines behave slightly differently and so
this is not an issue? I tried to investigate this on ARM but was unable to
make Xenomai on my Raspberry Pi produce ANY backtraces at all. It certainly
holds true for both 32 and 64-bit x86.

The other minor issue is the "-no-pie" problem that others have reported.
My investigation suggests that this can be resolved by simply having the
stage1 phase of wrap-link.sh include the "-no-pie" flag. The following
patch handles that issue when necessary, without breaking PIE in general:

/\/\/\ Begin Patch /\/\/\
--- a/xenomai-3.0.5/scripts/wrap-link.sh
+++ b/xenomai-3.0.5/scripts/wrap-link.sh
@@ -203,8 +203,13 @@
 done

 if $stage2; then
+ if gcc --verbose 2>&1 | grep --quiet default-pie ; then
+ no_pie="-no-pie"
+ else
+ no_pie=""
+ fi
  $verbose && set -x
- $dryrun $cc -o "$output.tmp" -Wl,-Ur -nostdlib $stage1_args
+ $dryrun $cc -o "$output.tmp" -Wl,-Ur $no_pie -nostdlib   $stage1_args
  $dryrun $cc -o "$output" "$output.tmp" $stage2_args
  $dryrun rm -f $output.tmp
 else
/\/\/\ End Patch /\/\/\

I hope these are helpful for others. Thanks for all the hard work on
Xenomai.

Warmest Regards,

Steve Cohen

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2017-09-05 17:57 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-30  1:17 [Xenomai] Issues building old drivers under Xenomai 3.0.5 Jim Langston
2017-08-30  2:38 ` [Xenomai] Two Minor Issues with Patches Stephen D. Cohen
2017-08-31 13:28   ` Philippe Gerum
2017-08-31 15:35   ` Philippe Gerum
2017-09-01  3:48     ` Stephen D. Cohen
2017-09-05 17:57       ` Philippe Gerum
2017-08-30  7:20 ` [Xenomai] Issues building old drivers under Xenomai 3.0.5 Philippe Gerum
2017-09-01 21:33   ` Jim Langston
2017-09-02  3:43     ` Stephen D. Cohen
2017-08-30 20:51 [Xenomai] Two Minor Issues, With Patches Stephen D. Cohen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.