Skip to contentSkip to conversation

Interesting circular dependency, how to solve?

Buildroot Thomas Petazzoni 3 participants 10 messages Jul 6, 2016 – Jul 7, 2016

lore
Share & tools
lore
#0 lore raw

Hello all,

Today, Paul (in Cc) reported on IRC an interesting problem: on a configuration with systemd enabled (and acting as udev provider), pciutils would fail to build due to libudev.h being missing.

After some investigation, "make graph-depends" revealed the origin of the problem: a very interesting circular dependency. Here is what make graph-depends thinks of the situation:

Recursion detected for : systemd
which is a dependency of: udev
which is a dependency of: pciutils
which is a dependency of: linux
which is a dependency of: cryptodev-linux
which is a dependency of: openssl
which is a dependency of: libcurl
which is a dependency of: systemd

So, starting from the bottom:

- When libcurl is enabled, systemd depends on it

- When OpenSSL is enabled, obviously, libcurl will use it for SSL support

- When cryptodev-linux is enabled, OpenSSL will depend on it to use crypto accelerators supported in the kernel via cryptodev-linux.

- cryptodev-linux being a kernel module, it depends on linux

- linux by itself (the kernel) does not depend on pciutils, but the linux tool "cpupower" (managed in linux-tool-cpupower) depends on pciutils

- pciutils depends on udev when available

- udev is provided by systemd.

So we have a dependency loop. This was not detected in the autobuilders because it requires the linux package to be enabled to trigger.

I'm not sure where to break the dependency loop here. The real problem is that cryptodev-linux does *NOT* require cpupower, it only needs the kernel itself. Does this means that our current architecture for packaging "tools" whose source code is part of the kernel as part of the "linux" package is wrong ?

Do you have some suggestions or ideas on how to solve this ? The only two solutions that I can find is:

- Arbitrarily break this dependency loop by removing some functionality (but I'm not sure where)

- Moving the cpupower build logic outside of the linux package.

The other question is how we can improve our autobuilder testing to detect such situations.

Thanks,

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#1 lore raw
Quoted 3 lines

- When cryptodev-linux is enabled, OpenSSL will depend on it to use crypto accelerators supported in the kernel via cryptodev-linux.

If I understand you correctly, this builds TWO things, right?

If this is the case, make it separate packages to build the kernel module then the userspace package.

Would that remove the dependency loop?

Andy

#2 lore raw

Hello,

Quoted 7 lines · ANDY KENNEDY
Quoted 2 lines

- When cryptodev-linux is enabled, OpenSSL will depend on it to use crypto accelerators supported in the kernel via cryptodev-linux.

If I understand you correctly, this builds TWO things, right?

If this is the case, make it separate packages to build the kernel module then the userspace package.

It builds a kernel module, so it has to depend on "linux", and it installs cryptodev.h, which OpenSSL needs. I am not sure splitting this package into two is really a good idea, though it would indeed solve the problem: all what OpenSSL needs at build time is the cryptodev.h header file. The kernel module can be built separately, and is only at runtime.

So, yes, one possibility is to break cryptodev-linux into two packages.

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#3 lore raw
Quoted 19 lines

-----Original Message-----
From: Thomas Petazzoni [mailto:thomas.petazzoni at free-electrons.com]
Sent: Wednesday, July 06, 2016 1:20 PM
To: ANDY KENNEDY
Cc: buildroot at uclibc.org; paul.ashford at zurria.co.uk
Subject: Re: [Buildroot] Interesting circular dependency, how to solve?

Hello,

Quoted 7 lines · ANDY KENNEDY
Quoted 2 lines

- When cryptodev-linux is enabled, OpenSSL will depend on it to use crypto accelerators supported in the kernel via cryptodev-linux.

If I understand you correctly, this builds TWO things, right?

If this is the case, make it separate packages to build the kernel module then the userspace package.

Quoted 8 lines

It builds a kernel module, so it has to depend on "linux", and it installs cryptodev.h, which OpenSSL needs. I am not sure splitting this package into two is really a good idea, though it would indeed solve the problem: all what OpenSSL needs at build time is the cryptodev.h header file. The kernel module can be built separately, and is only at runtime.

So, yes, one possibility is to break cryptodev-linux into two packages.

You _could_ do it via a hidden option that is selected by the other option. Then, it is still "one" package, however, the make dependency tree would see it as two.

Andy

#7 lore raw
In reply to Thomas Petazzoni

Thomas, Paul, All,

On 2016-07-06 17:56 +0200, Thomas Petazzoni spake thusly:

Quoted 8 lines

Today, Paul (in Cc) reported on IRC an interesting problem: on a configuration with systemd enabled (and acting as udev provider), pciutils would fail to build due to libudev.h being missing.

After some investigation, "make graph-depends" revealed the origin of the problem: a very interesting circular dependency. Here is what make graph-depends thinks of the situation:

Quoted 8 lines

Recursion detected for : systemd
which is a dependency of: udev
which is a dependency of: pciutils
which is a dependency of: linux
which is a dependency of: cryptodev-linux
which is a dependency of: openssl
which is a dependency of: libcurl
which is a dependency of: systemd

Hmmm... make itself should have spit a warning of its own. However, I could not see a way to have make error out; it is a mere warning... :-(

Quoted 12 lines

So, starting from the bottom:

- When libcurl is enabled, systemd depends on it

- When OpenSSL is enabled, obviously, libcurl will use it for SSL support

- When cryptodev-linux is enabled, OpenSSL will depend on it to use crypto accelerators supported in the kernel via cryptodev-linux.

- cryptodev-linux being a kernel module, it depends on linux

Quoted 7 lines

- linux by itself (the kernel) does not depend on pciutils, but the linux tool "cpupower" (managed in linux-tool-cpupower) depends on pciutils

- pciutils depends on udev when available

- udev is provided by systemd.

Indeed. :-/

Quoted 2 lines

So we have a dependency loop. This was not detected in the autobuilders because it requires the linux package to be enabled to trigger.

Maybe we could have some autobuilders use our defconfigs as starting points for randpackageconfig? Most (all?) of our defconfigs have a kernel enabled, so we could probably catch such a situation...

Quoted 6 lines

I'm not sure where to break the dependency loop here. The real problem is that cryptodev-linux does *NOT* require cpupower, it only needs the kernel itself. Does this means that our current architecture for packaging "tools" whose source code is part of the kernel as part of the "linux" package is wrong ?

Quoted 7 lines

Do you have some suggestions or ideas on how to solve this ? The only two solutions that I can find is:

- Arbitrarily break this dependency loop by removing some functionality (but I'm not sure where)

- Moving the cpupower build logic outside of the linux package.

I think this is the best solution. We could make the linux-tools be built in their own package, vampirising the sources from the kernel (or even building in there) by way of carefully crafted _PATCH_DEPENDENCIES (but I'm afraid patch dependencies are still used to build the dependency graph anyway... :-/ ).

I will look at it...

Quoted 2 lines

The other question is how we can improve our autobuilder testing to detect such situations.

See above: have a randcom defconfig be picked and use it as a starting point. We have almost all architectures covered, except maybe a few corner cases for exotic stuff like bfin or arc...

Regards,
Yann E. MORIN.

Quoted 11 lines

Thanks,

Thomas

Signature · 7 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#4 lore raw
In reply to Thomas Petazzoni

Thomas, Andy, All,

On 2016-07-06 20:20 +0200, Thomas Petazzoni spake thusly:

Quoted 9 lines · ANDY KENNEDY
Quoted 7 lines
Quoted 2 lines

- When cryptodev-linux is enabled, OpenSSL will depend on it to use crypto accelerators supported in the kernel via cryptodev-linux.

If I understand you correctly, this builds TWO things, right?

If this is the case, make it separate packages to build the kernel module then the userspace package.

Quoted 8 lines

It builds a kernel module, so it has to depend on "linux", and it installs cryptodev.h, which OpenSSL needs. I am not sure splitting this package into two is really a good idea, though it would indeed solve the problem: all what OpenSSL needs at build time is the cryptodev.h header file. The kernel module can be built separately, and is only at runtime.

So, yes, one possibility is to break cryptodev-linux into two packages.

But then we would probably have to do it for other packages that build both a kernel module and userland stuff, no?

I'm not sure I like that... :-/

I think the best option would be to break at the linux-tools.

Regards,
Yann E. MORIN.

Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#8 lore raw
In reply to Yann E. MORIN

Thomas, Paul, All,

On 2016-07-07 18:33 +0200, Yann E. MORIN spake thusly:

Quoted 18 lines

On 2016-07-06 17:56 +0200, Thomas Petazzoni spake thusly:

Quoted 8 lines

Today, Paul (in Cc) reported on IRC an interesting problem: on a configuration with systemd enabled (and acting as udev provider), pciutils would fail to build due to libudev.h being missing.

After some investigation, "make graph-depends" revealed the origin of the problem: a very interesting circular dependency. Here is what make graph-depends thinks of the situation:

Quoted 8 lines

Recursion detected for : systemd
which is a dependency of: udev
which is a dependency of: pciutils
which is a dependency of: linux
which is a dependency of: cryptodev-linux
which is a dependency of: openssl
which is a dependency of: libcurl
which is a dependency of: systemd

Quoted 2 lines

Hmmm... make itself should have spit a warning of its own. However, I could not see a way to have make error out; it is a mere warning... :-(

Indeed it does catch it. But not until it is time for it to actuall build openssl:

make[1]: Circular /home/ymorin/dev/buildroot/O/build/openssl-1.0.2h/.stamp_configured <- cryptodev-linux dependency dropped. >>> openssl 1.0.2h Downloading

DAng. Why doesn't it detect it at the beginning of the build? And why can't we tell make to consider it an error rather than a warning?

Damn... :-/

Regards,
Yann E. MORIN.

Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#5 lore raw
In reply to Yann E. MORIN

Hello,

Quoted 6 lines · Yann E. MORIN

But then we would probably have to do it for other packages that build both a kernel module and userland stuff, no?

I'm not sure I like that... :-/

I think the best option would be to break at the linux-tools.

Agreed.

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#9 lore raw
In reply to Yann E. MORIN

Hello,

Quoted 3 lines · Yann E. MORIN

Maybe we could have some autobuilders use our defconfigs as starting points for randpackageconfig? Most (all?) of our defconfigs have a kernel enabled, so we could probably catch such a situation...

My idea for this topic is more something like randomly, enabling the Linux kernel package and depending on the selected architecture, use a given defconfig (with a table of architecture <-> defconfig) match in the autobuild-run script.

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#6 lore raw
In reply to Thomas Petazzoni

Thomas, All,

On 2016-07-07 21:26 +0200, Thomas Petazzoni spake thusly:

Quoted 8 lines · Yann E. MORIN
Quoted 6 lines

But then we would probably have to do it for other packages that build both a kernel module and userland stuff, no?

I'm not sure I like that... :-/

I think the best option would be to break at the linux-tools.

Agreed.

OK, done locally, I've been a little bit side-tracked, so it is not completely tested yet. will spin it tomorrow...

Regards,
Yann E. MORIN.

Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'