Skip to content

Commit 7496a2b

Browse files
authored
Merge pull request #802 from deinok/cross-fix
Set the build-rootfs like the other repos
2 parents c5fe434 + 127fd87 commit 7496a2b

File tree

2 files changed

+117
-8
lines changed

2 files changed

+117
-8
lines changed

cross/arm/trusty-lttng-2.4.patch

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
From e72c9d7ead60e3317bd6d1fade995c07021c947b Mon Sep 17 00:00:00 2001
2+
From: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
3+
Date: Thu, 7 May 2015 13:25:04 -0400
4+
Subject: [PATCH] Fix: building probe providers with C++ compiler
5+
6+
Robert Daniels wrote:
7+
> > I'm attempting to use lttng userspace tracing with a C++ application
8+
> > on an ARM platform. I'm using GCC 4.8.4 on Linux 3.14 with the 2.6
9+
> > release of lttng. I've compiled lttng-modules, lttng-ust, and
10+
> > lttng-tools and have been able to get a simple test working with C
11+
> > code. When I attempt to run the hello.cxx test on my target it will
12+
> > segfault.
13+
>
14+
>
15+
> I spent a little time digging into this issue and finally discovered the
16+
> cause of my segfault with ARM C++ tracepoints.
17+
>
18+
> There is a struct called 'lttng_event' in ust-events.h which contains an
19+
> empty union 'u'. This was the cause of my issue. Under C, this empty union
20+
> compiles to a zero byte member while under C++ it compiles to a one byte
21+
> member, and in my case was four-byte aligned which caused my C++ code to
22+
> have the 'cds_list_head node' offset incorrectly by four bytes. This lead
23+
> to an incorrect linked list structure which caused my issue.
24+
>
25+
> Since this union is empty, I simply removed it from the struct and everything
26+
> worked correctly.
27+
>
28+
> I don't know the history or purpose behind this empty union so I'd like to
29+
> know if this is a safe fix. If it is I can submit a patch with the union
30+
> removed.
31+
32+
That's a very nice catch!
33+
34+
We do not support building tracepoint probe provider with
35+
g++ yet, as stated in lttng-ust(3):
36+
37+
"- Note for C++ support: although an application instrumented with
38+
tracepoints can be compiled with g++, tracepoint probes should be
39+
compiled with gcc (only tested with gcc so far)."
40+
41+
However, if it works fine with this fix, then I'm tempted to take it,
42+
especially because removing the empty union does not appear to affect
43+
the layout of struct lttng_event as seen from liblttng-ust, which must
44+
be compiled with a C compiler, and from probe providers compiled with
45+
a C compiler. So all we are changing is the layout of a probe provider
46+
compiled with a C++ compiler, which is anyway buggy at the moment,
47+
because it is not compatible with the layout expected by liblttng-ust
48+
compiled with a C compiler.
49+
50+
Reported-by: Robert Daniels <robert.daniels@vantagecontrols.com>
51+
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
52+
---
53+
include/lttng/ust-events.h | 2 --
54+
1 file changed, 2 deletions(-)
55+
56+
diff --git a/usr/include/lttng/ust-events.h b/usr/include/lttng/ust-events.h
57+
index 328a875..3d7a274 100644
58+
--- a/usr/include/lttng/ust-events.h
59+
+++ b/usr/include/lttng/ust-events.h
60+
@@ -407,8 +407,6 @@ struct lttng_event {
61+
void *_deprecated1;
62+
struct lttng_ctx *ctx;
63+
enum lttng_ust_instrumentation instrumentation;
64+
- union {
65+
- } u;
66+
struct cds_list_head node; /* Event list in session */
67+
struct cds_list_head _deprecated2;
68+
void *_deprecated3;
69+
--
70+
2.7.4

cross/build-rootfs.sh

Lines changed: 47 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ usage()
44
{
55
echo "Usage: $0 [BuildArch] [LinuxCodeName] [lldbx.y] [--skipunmount]"
66
echo "BuildArch can be: arm(default), armel, arm64, x86"
7-
echo "LinuxCodeName - optional, Code name for Linux, can be: trusty(default), vivid, wily, xenial, zesty, bionic. If BuildArch is armel, LinuxCodeName is jessie(default) or tizen."
8-
echo "lldbx.y - optional, LLDB version, can be: lldb3.6(default), lldb3.8, lldb3.9, lldb4.0, no-lldb"
7+
echo "LinuxCodeName - optional, Code name for Linux, can be: trusty(default), vivid, wily, xenial, zesty, bionic, alpine. If BuildArch is armel, LinuxCodeName is jessie(default) or tizen."
8+
echo "lldbx.y - optional, LLDB version, can be: lldb3.6(default), lldb3.8, lldb3.9, lldb4.0, no-lldb. Ignored for alpine"
99
echo "--skipunmount - optional, will skip the unmount of rootfs folder."
1010
exit 1
1111
}
@@ -22,21 +22,36 @@ __SkipUnmount=0
2222
# base development support
2323
__UbuntuPackages="build-essential"
2424

25+
__AlpinePackages="alpine-base"
26+
__AlpinePackages+=" build-base"
27+
__AlpinePackages+=" linux-headers"
28+
__AlpinePackages+=" lldb-dev"
29+
__AlpinePackages+=" llvm-dev"
30+
2531
# symlinks fixer
2632
__UbuntuPackages+=" symlinks"
2733

2834
# CoreCLR and CoreFX dependencies
29-
__UbuntuPackages+=" gettext"
30-
__UbuntuPackages+=" libunwind8-dev"
31-
__UbuntuPackages+=" liblttng-ust-dev"
3235
__UbuntuPackages+=" libicu-dev"
36+
__UbuntuPackages+=" liblttng-ust-dev"
37+
__UbuntuPackages+=" libunwind8-dev"
38+
39+
__AlpinePackages+=" gettext-dev"
40+
__AlpinePackages+=" icu-dev"
41+
__AlpinePackages+=" libunwind-dev"
42+
__AlpinePackages+=" lttng-ust-dev"
3343

3444
# CoreFX dependencies
3545
__UbuntuPackages+=" libcurl4-openssl-dev"
3646
__UbuntuPackages+=" libkrb5-dev"
3747
__UbuntuPackages+=" libssl-dev"
3848
__UbuntuPackages+=" zlib1g-dev"
3949

50+
__AlpinePackages+=" curl-dev"
51+
__AlpinePackages+=" krb5-dev"
52+
__AlpinePackages+=" openssl-dev"
53+
__AlpinePackages+=" zlib-dev"
54+
4055
__UnprocessedBuildArgs=
4156
for i in "$@" ; do
4257
lowerI="$(echo $i | awk '{print tolower($0)}')"
@@ -48,10 +63,14 @@ for i in "$@" ; do
4863
arm)
4964
__BuildArch=arm
5065
__UbuntuArch=armhf
66+
__AlpineArch=armhf
67+
__QEMUArch=arm
5168
;;
5269
arm64)
5370
__BuildArch=arm64
5471
__UbuntuArch=arm64
72+
__AlpineArch=aarch64
73+
__QEMUArch=aarch64
5574
;;
5675
armel)
5776
__BuildArch=armel
@@ -71,10 +90,10 @@ for i in "$@" ; do
7190
__LLDB_Package="lldb-3.8-dev"
7291
;;
7392
lldb3.9)
74-
__LLDB_Package="lldb-3.9-dev"
93+
__LLDB_Package="liblldb-3.9-dev"
7594
;;
7695
lldb4.0)
77-
__LLDB_Package="lldb-4.0-dev"
96+
__LLDB_Package="liblldb-4.0-dev"
7897
;;
7998
no-lldb)
8099
unset __LLDB_Package
@@ -118,6 +137,10 @@ for i in "$@" ; do
118137
__UbuntuRepo=
119138
__Tizen=tizen
120139
;;
140+
alpine)
141+
__LinuxCodeName=alpine
142+
__UbuntuRepo=
143+
;;
121144
--skipunmount)
122145
__SkipUnmount=1
123146
;;
@@ -145,7 +168,22 @@ if [ -d "$__RootfsDir" ]; then
145168
rm -rf $__RootfsDir
146169
fi
147170

148-
if [[ -n $__LinuxCodeName ]]; then
171+
if [[ "$__LinuxCodeName" == "alpine" ]]; then
172+
__ApkToolsVersion=2.9.1
173+
__AlpineVersion=3.7
174+
__ApkToolsDir=$(mktemp -d)
175+
wget https://github.com/alpinelinux/apk-tools/releases/download/v$__ApkToolsVersion/apk-tools-$__ApkToolsVersion-x86_64-linux.tar.gz -P $__ApkToolsDir
176+
tar -xf $__ApkToolsDir/apk-tools-$__ApkToolsVersion-x86_64-linux.tar.gz -C $__ApkToolsDir
177+
mkdir -p $__RootfsDir/usr/bin
178+
cp -v /usr/bin/qemu-$__QEMUArch-static $__RootfsDir/usr/bin
179+
$__ApkToolsDir/apk-tools-$__ApkToolsVersion/apk \
180+
-X http://dl-cdn.alpinelinux.org/alpine/v$__AlpineVersion/main \
181+
-X http://dl-cdn.alpinelinux.org/alpine/v$__AlpineVersion/community \
182+
-X http://dl-cdn.alpinelinux.org/alpine/edge/testing \
183+
-U --allow-untrusted --root $__RootfsDir --arch $__AlpineArch --initdb \
184+
add $__AlpinePackages
185+
rm -r $__ApkToolsDir
186+
elif [[ -n $__LinuxCodeName ]]; then
149187
qemu-debootstrap --arch $__UbuntuArch $__LinuxCodeName $__RootfsDir $__UbuntuRepo
150188
cp $__CrossDir/$__BuildArch/sources.list.$__LinuxCodeName $__RootfsDir/etc/apt/sources.list
151189
chroot $__RootfsDir apt-get update
@@ -160,6 +198,7 @@ if [[ -n $__LinuxCodeName ]]; then
160198
if [[ "$__BuildArch" == "arm" && "$__LinuxCodeName" == "trusty" ]]; then
161199
pushd $__RootfsDir
162200
patch -p1 < $__CrossDir/$__BuildArch/trusty.patch
201+
patch -p1 < $__CrossDir/$__BuildArch/trusty-lttng-2.4.patch
163202
popd
164203
fi
165204
elif [ "$__Tizen" == "tizen" ]; then

0 commit comments

Comments
 (0)