[syslog-ng] cross compiling syslog-ng

Scheidler, Balázs balazs.scheidler at balabit.com
Thu Oct 5 12:35:33 UTC 2017


hi,

I've figured I would give syslog-ng cross compilation a spin to check if
everything is all right with our sources.

Here's a description on how I've cross-compiled syslog-ng to arm64.


*1) toolchain*
I've used the docker based cross-compile toolchain from here:
https://github.com/dockcross/dockcross

You'll need docker on your build machine, see docker.com for intallation
instructions.

To use that, you'll only need to launch a docker command line and it would
automatically fetch the image from the docker registry. I've used
linux-arm64 as an example, but I guess the others would also work.

*2) sources*

You will need the release tarball. Please note that you can download both
the release tarball and a git snaphot from github, but you'll definitely
need the release tarball if you don't have all the build requirements
installed (automake, libtool and friends).

I've used
https://github.com/balabit/syslog-ng/releases/download/syslog-ng-3.12.1/syslog-ng-3.12.1.tar.gz

3) get the dockcross helper

```
$ docker run --rm dockcross/linux-arm64 > dockcross
$ chmod +x dockcross
```

*4) launch the cross-compile environment*

Extract the sources (e.g. tar xvfz syslog-ng-3.12.1.tar.gz) into a
directory, cd into it and launch the environment:

```
$ dockcross bash
```

This will give you a shell within the container, with a /work directory
containing the sources.

*5) install dependencies*

```
# this one fixes an issue within the container, "cpp" is unfortunately only
available
# with a versioned binary, which the configure script does not find.
$ sudo ln -s /usr/bin/aarch64-linux-gnu-cpp-4.9
/usr/bin/aarch64-linux-gnu-cpp

# this is the minimal set of dependencies to compile syslog-ng, you might
need others
# the bundled sources should however give you a pretty ok feature set
$ sudo apt-get install libglib2.0-dev:arm64 pkg-config:arm64
```

*6) build*

```
$ mkdir build
$ cd build
$ /work/configure --host aarch64-linux-gnu
<long configure output>
$ make
```

*7) install*

```
$ make install DESTDIR=/work/build/install
```

The resulting set of binaries you will find in /work/build/install, as if
it was installed in the root system (e.g. /usr/local/bin/syslog-ng would
become /work/build/install/usr/local/bin/syslog-ng)

*8) collect binaries*

Exit the docker container, your build products will be in the "build"
subdirectory of your source tree, with build/install containing the final
binaries.

bazsi at bzorp:~/src/syslog-ng-3.12.1/build/install$ file
usr/local/sbin/syslog-ng
usr/local/sbin/syslog-ng: ELF 64-bit LSB executable, ARM aarch64, version 1
(SYSV), dynamically linked, interpreter /lib/ld-linux-aarch64.so.1, for
GNU/Linux 3.7.0, BuildID[sha1]=424c7a32112262725b267e6043c25bd40d039568,
not stripped

I hope this helps.

-- 
Bazsi

On Thu, Oct 5, 2017 at 10:37 AM, Scheidler, Balázs <
balazs.scheidler at balabit.com> wrote:

> Hi,
>
> This might actually be a libtool issue, trying to locate the file in an
> invalid location. Do you have libtool in your toolchain? In order to use
> the one in your toolchain, you will need the complete set of autotools and
> rerun autogen.sh to regenerate all build files.
>
> BTW: the AX_PREFIX_CONFIG_H macro is also part of autoconf-archive (
> https://www.gnu.org/software/autoconf-archive/ax_prefix_config_h.html),
> but probably a later version than what you have.
>
> But you can always add these macros by downloading them explicitly and
> adding them to the m4 subdirectory.
>
> --
> Bazsi
>
> On Wed, Oct 4, 2017 at 4:35 PM, Benoit Duffez <notifications at github.com>
> wrote:
>
>> I have not solved it. It accepts to compile but the linker seems to fail:
>>
>>   CCLD   lib/libsyslog-ng.la
>> libtool: link: warning: library `/opt/toolchains/sysroots/cortexa9hf-neon-poky-linux-gnueabi/usr/lib/libgmodule-2.0.la' was moved.
>> libtool: link: warning: library `/opt/toolchains/sysroots/cortexa9hf-neon-poky-linux-gnueabi/usr/lib/libgthread-2.0.la' was moved.
>> libtool: link: warning: library `/opt/toolchains/sysroots/cortexa9hf-neon-poky-linux-gnueabi/usr/lib/libglib-2.0.la' was moved.
>> libtool: link: warning: library `/opt/toolchains/sysroots/cortexa9hf-neon-poky-linux-gnueabi/usr/lib/libpcre.la' was moved.
>> libtool: link: warning: library `/opt/toolchains/sysroots/cortexa9hf-neon-poky-linux-gnueabi/usr/lib/libuuid.la' was moved.
>> sed: can't read /usr/lib/libglib-2.0.la: No such file or directory
>> libtool: link: `=/usr/lib/libglib-2.0.la' is not a valid libtool archive
>> Makefile:7092: recipe for target 'lib/libsyslog-ng.la' failed
>> make[2]: *** [lib/libsyslog-ng.la] Error 1
>> Makefile:16376: recipe for target 'all-recursive' failed
>> make[1]: *** [all-recursive] Error 1
>> Makefile:6285: recipe for target 'all' failed
>> make: *** [all] Error 2
>>
>> I think it's a PATH issue because I do have this libglib-2.0.la file,
>> just not at /usr/bin (but in a subfolder of /opt/toolchains)
>>
>>>> You are receiving this because you are subscribed to this thread.
>> Reply to this email directly, view it on GitHub
>> <https://github.com/balabit/syslog-ng/issues/1705#issuecomment-334176270>,
>> or mute the thread
>> <https://github.com/notifications/unsubscribe-auth/AArldnMjDwe5Mfaj6m3FPTfidBvM_sC_ks5so5fCgaJpZM4PtokL>
>> .
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.balabit.hu/pipermail/syslog-ng/attachments/20171005/6c025c52/attachment.html>


More information about the syslog-ng mailing list