Skip to contentSkip to conversation

Circular dependency between <linux/kernel.h> and <asm/bug.h> on ARM

DISCUSSION Ben Hutchings 5 participants 7 messages Jan 2, 2012 – Jan 6, 2012

lore
Share & tools
lore
#0 lore raw

Commit 87e040b6456fd3416a1f6831c1eedaef5c0a94ff ("ARM: 7017/1: Use generic BUG() handler") makes BUG() use BUILD_BUG_ON(). However, BUILD_BUG_ON() is not defined in <linux/bug.h> but in <linux/kernel.h>.

arch/include/asm/bug.h does not include <linux/kernel.h> and *cannot* do so because the latter already includes <asm/bug.h>.

Maybe BUILD_BUG_ON() should be moved out to a header of its own, or else this particular use should be moved to some other file. This needs to be fixed somehow, as it obviously leads to build failures, e.g.:

https://buildd.debian.org/status/fetch.php?pkg=linux-2.6&arch=armel&ver=3.2~rc7-1~experimental.1&stamp=1325142904

Ben.

Signature · 9 lines
Ben Hutchings
All the simple programs have been written, and all the good names taken.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 828 bytes
Desc: This is a digitally signed message part
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20120102/df7dcba0/attachment.sig>
#1 lore raw
Quoted 6 lines · Ben Hutchings

Commit 87e040b6456fd3416a1f6831c1eedaef5c0a94ff ("ARM: 7017/1: Use generic BUG() handler") makes BUG() use BUILD_BUG_ON(). ?However, BUILD_BUG_ON() is not defined in <linux/bug.h> but in <linux/kernel.h>.

arch/include/asm/bug.h does not include <linux/kernel.h> and *cannot* do so because the latter already includes <asm/bug.h>.

Sure it can, but it's not ideal. Since the BUILD_BUG_ON is only used in bug.h in a #define, it will be resolved below the includes of either so there should be no ordering issue between the two.

I coincidentally posted a patch earlier to do just that, I didn't see your email until later.

Quoted 5 lines

Maybe BUILD_BUG_ON() should be moved out to a header of its own, or else this particular use should be moved to some other file. ?This needs to be fixed somehow, as it obviously leads to build failures, e.g.:

https://buildd.debian.org/status/fetch.php?pkg=linux-2.6&arch=armel&ver=3.2~rc7-1~experimental.1&stamp=1325142904

Or perhaps moving BUILD_BUG_ON to include/linux/bug.h?

The quickest fix for now might be to take out the BUILD_BUG_ON(), especially so close to 3.2-final.

-Olof

#2 lore raw

Hi Ben, Olof,

Quoted 19 lines · Olof Johansson
Quoted 6 lines · Ben Hutchings

Commit 87e040b6456fd3416a1f6831c1eedaef5c0a94ff ("ARM: 7017/1: Use generic BUG() handler") makes BUG() use BUILD_BUG_ON(). ?However, BUILD_BUG_ON() is not defined in <linux/bug.h> but in <linux/kernel.h>.

arch/include/asm/bug.h does not include <linux/kernel.h> and *cannot* do so because the latter already includes <asm/bug.h>.

Sure it can, but it's not ideal. Since the BUILD_BUG_ON is only used in bug.h in a #define, it will be resolved below the includes of either so there should be no ordering issue between the two.

I coincidentally posted a patch earlier to do just that, I didn't see your email until later.

Quoted 4 lines

Maybe BUILD_BUG_ON() should be moved out to a header of its own, or else this particular use should be moved to some other file. ?This needs to be fixed somehow, as it obviously leads to build failures, e.g.:

Quoted 6 lines
Quoted 1 line

https://buildd.debian.org/status/fetch.php?pkg=linux-2.6&arch=armel&ver=3.2~rc7-1~experimental.1&stamp=1325142904

Or perhaps moving BUILD_BUG_ON to include/linux/bug.h?

The quickest fix for now might be to take out the BUILD_BUG_ON(), especially so close to 3.2-final.

Yes I like that idea as the check isn't funtional. Perhaps ultimately the BUILD_BUG_ON check for sizeof(struct bug_entry) should really go in lib/bug.c. Something like, in the header:

#define GENERIC_BUG_ENTRY_SIZE 12

and then in lib/bug.c:

#ifdef GENERIC_BUG_ENTRY_SIZE BUILD_BUG_ON(GENERIC_BUG_ENTRY_SIZE != sizeof(struct bug_entry)) #endif

The other more fragile option might be to make sure all files include <linux/kernel.h>?

Regards,
Simon

Quoted 3 lines

-Olof

#3 lore raw
In reply to Olof Johansson
Quoted 11 lines · Olof Johansson
Quoted 6 lines · Ben Hutchings

Commit 87e040b6456fd3416a1f6831c1eedaef5c0a94ff ("ARM: 7017/1: Use generic BUG() handler") makes BUG() use BUILD_BUG_ON(). ?However, BUILD_BUG_ON() is not defined in <linux/bug.h> but in <linux/kernel.h>.

arch/include/asm/bug.h does not include <linux/kernel.h> and *cannot* do so because the latter already includes <asm/bug.h>.

Sure it can, but it's not ideal. Since the BUILD_BUG_ON is only used in bug.h in a #define, it will be resolved below the includes of either so there should be no ordering issue between the two.

I disagree - we should not be creating circular dependencies. This creates a mess, and uncertain results. For instance, if we include linux/bug.h or asm/bug.h before linux/kernel.h has been included, then we end up with linux/kernel.h being parsed without a definition for BUG_ON().

However, if linux/kernel.h is included first, we start parsing that, include asm/bug.h, asm/bug.h then includes linux/kernel.h which produces an empty file, and then we continue parsing asm/bug.h _without_ BUILD_BUG_ON() defined.

So, adding linux/kernel.h does _not_ solve the problem. It solves the problem for _some_ cases only.

Quoted 7 lines
Quoted 5 lines

Maybe BUILD_BUG_ON() should be moved out to a header of its own, or else this particular use should be moved to some other file. ?This needs to be fixed somehow, as it obviously leads to build failures, e.g.:

https://buildd.debian.org/status/fetch.php?pkg=linux-2.6&arch=armel&ver=3.2~rc7-1~experimental.1&stamp=1325142904

Or perhaps moving BUILD_BUG_ON to include/linux/bug.h?

and change linux/kernel.h to include linux/bug.h rather than asm/bug.h.

Quoted 2 lines

The quickest fix for now might be to take out the BUILD_BUG_ON(), especially so close to 3.2-final.

I think just remove the BUILD_BUG_ON. Other architectures have done without it, so I see no reason we can't do as well.

#4 lore raw

Hi Russell,

Quoted 35 lines · Russell King - ARM Linux
Quoted 11 lines · Olof Johansson
Quoted 6 lines · Ben Hutchings

Commit 87e040b6456fd3416a1f6831c1eedaef5c0a94ff ("ARM: 7017/1: Use generic BUG() handler") makes BUG() use BUILD_BUG_ON(). ?However, BUILD_BUG_ON() is not defined in <linux/bug.h> but in <linux/kernel.h>.

arch/include/asm/bug.h does not include <linux/kernel.h> and *cannot* do so because the latter already includes <asm/bug.h>.

Sure it can, but it's not ideal. Since the BUILD_BUG_ON is only used in bug.h in a #define, it will be resolved below the includes of either so there should be no ordering issue between the two.

I disagree - we should not be creating circular dependencies. ?This creates a mess, and uncertain results. ?For instance, if we include linux/bug.h or asm/bug.h before linux/kernel.h has been included, then we end up with linux/kernel.h being parsed without a definition for BUG_ON().

However, if linux/kernel.h is included first, we start parsing that, include asm/bug.h, asm/bug.h then includes linux/kernel.h which produces an empty file, and then we continue parsing asm/bug.h _without_ BUILD_BUG_ON() defined.

So, adding linux/kernel.h does _not_ solve the problem. ?It solves the problem for _some_ cases only.

Quoted 7 lines
Quoted 5 lines

Maybe BUILD_BUG_ON() should be moved out to a header of its own, or else this particular use should be moved to some other file. ?This needs to be fixed somehow, as it obviously leads to build failures, e.g.:

https://buildd.debian.org/status/fetch.php?pkg=linux-2.6&arch=armel&ver=3.2~rc7-1~experimental.1&stamp=1325142904

Or perhaps moving BUILD_BUG_ON to include/linux/bug.h?

Quoted 7 lines

and change linux/kernel.h to include linux/bug.h rather than asm/bug.h.

Quoted 2 lines

The quickest fix for now might be to take out the BUILD_BUG_ON(), especially so close to 3.2-final.

I think just remove the BUILD_BUG_ON. ?Other architectures have done without it, so I see no reason we can't do as well.

OK I will send a patch to do this, it is safest. Any interest in (for a later release) putting a check in the C file as I suggested?

Regards,
Simon

#5 lore raw
In reply to Russell King - ARM Linux
Quoted 31 lines · Russell King - ARM Linux
Quoted 11 lines · Olof Johansson
Quoted 6 lines · Ben Hutchings

Commit 87e040b6456fd3416a1f6831c1eedaef5c0a94ff ("ARM: 7017/1: Use generic BUG() handler") makes BUG() use BUILD_BUG_ON(). ?However, BUILD_BUG_ON() is not defined in <linux/bug.h> but in <linux/kernel.h>.

arch/include/asm/bug.h does not include <linux/kernel.h> and *cannot* do so because the latter already includes <asm/bug.h>.

Sure it can, but it's not ideal. Since the BUILD_BUG_ON is only used in bug.h in a #define, it will be resolved below the includes of either so there should be no ordering issue between the two.

I disagree - we should not be creating circular dependencies. ?This creates a mess, and uncertain results. ?For instance, if we include linux/bug.h or asm/bug.h before linux/kernel.h has been included, then we end up with linux/kernel.h being parsed without a definition for BUG_ON().

However, if linux/kernel.h is included first, we start parsing that, include asm/bug.h, asm/bug.h then includes linux/kernel.h which produces an empty file, and then we continue parsing asm/bug.h _without_ BUILD_BUG_ON() defined.

So, adding linux/kernel.h does _not_ solve the problem. ?It solves the problem for _some_ cases only.

Quoted 4 lines
Quoted 4 lines

Maybe BUILD_BUG_ON() should be moved out to a header of its own, or else this particular use should be moved to some other file. ?This needs to be fixed somehow, as it obviously leads to build failures, e.g.:

Quoted 5 lines
Quoted 3 lines
Quoted 1 line

https://buildd.debian.org/status/fetch.php?pkg=linux-2.6&arch=armel&ver=3.2~rc7-1~experimental.1&stamp=1325142904

Or perhaps moving BUILD_BUG_ON to include/linux/bug.h?

and change linux/kernel.h to include linux/bug.h rather than asm/bug.h.

Actually, kernel.h doesn't need to include any variant of bug.h at all.

I started on cleaning this up a few weeks back, but didn't have the time to get it ready for 3.3 -- so my intent is to do so for linux-next that will be the 3.4 release. The Work In Progress can be seen here:

http://git.kernel.org/?p=linux/kernel/git/paulg/linux.git;a=shortlog;h=refs/heads/bug.h-cleanup-WIP

I only mention it here since I'd hate to see anyone waste time on duplicating work that is already done.

Thanks,
Paul.

---

Quoted 11 lines
Quoted 3 lines

The quickest fix for now might be to take out the BUILD_BUG_ON(), especially so close to 3.2-final.

I think just remove the BUILD_BUG_ON. ?Other architectures have done without it, so I see no reason we can't do as well.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo at vger.kernel.org
More majordomo info at ?http://vger.kernel.org/majordomo-info.html Please read the FAQ at ?http://www.tux.org/lkml/

#6 lore raw
Quoted 41 lines · Paul Gortmaker
Quoted 31 lines · Russell King - ARM Linux
Quoted 11 lines · Olof Johansson
Quoted 6 lines · Ben Hutchings

Commit 87e040b6456fd3416a1f6831c1eedaef5c0a94ff ("ARM: 7017/1: Use generic BUG() handler") makes BUG() use BUILD_BUG_ON(). ?However, BUILD_BUG_ON() is not defined in <linux/bug.h> but in <linux/kernel.h>.

arch/include/asm/bug.h does not include <linux/kernel.h> and *cannot* do so because the latter already includes <asm/bug.h>.

Sure it can, but it's not ideal. Since the BUILD_BUG_ON is only used in bug.h in a #define, it will be resolved below the includes of either so there should be no ordering issue between the two.

I disagree - we should not be creating circular dependencies. ?This creates a mess, and uncertain results. ?For instance, if we include linux/bug.h or asm/bug.h before linux/kernel.h has been included, then we end up with linux/kernel.h being parsed without a definition for BUG_ON().

However, if linux/kernel.h is included first, we start parsing that, include asm/bug.h, asm/bug.h then includes linux/kernel.h which produces an empty file, and then we continue parsing asm/bug.h _without_ BUILD_BUG_ON() defined.

So, adding linux/kernel.h does _not_ solve the problem. ?It solves the problem for _some_ cases only.

Quoted 4 lines
Quoted 4 lines

Maybe BUILD_BUG_ON() should be moved out to a header of its own, or else this particular use should be moved to some other file. ?This needs to be fixed somehow, as it obviously leads to build failures, e.g.:

Quoted 5 lines
Quoted 3 lines
Quoted 1 line

https://buildd.debian.org/status/fetch.php?pkg=linux-2.6&arch=armel&ver=3.2~rc7-1~experimental.1&stamp=1325142904

Or perhaps moving BUILD_BUG_ON to include/linux/bug.h?

and change linux/kernel.h to include linux/bug.h rather than asm/bug.h.

Actually, kernel.h doesn't need to include any variant of bug.h at all.

Quoted 8 lines

I started on cleaning this up a few weeks back, but didn't have the time to get it ready for 3.3 -- so my intent is to do so for linux-next that will be the 3.4 release. ?The Work In Progress can be seen here:

http://git.kernel.org/?p=linux/kernel/git/paulg/linux.git;a=shortlog;h=refs/heads/bug.h-cleanup-WIP

I only mention it here since I'd hate to see anyone waste time on duplicating work that is already done.

Thanks Paul, I hope it goes well.

Regards,
Simon

Quoted 17 lines

Thanks,
Paul.

---

Quoted 11 lines
Quoted 3 lines

The quickest fix for now might be to take out the BUILD_BUG_ON(), especially so close to 3.2-final.

I think just remove the BUILD_BUG_ON. ?Other architectures have done without it, so I see no reason we can't do as well.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo at vger.kernel.org
More majordomo info at ?http://vger.kernel.org/majordomo-info.html Please read the FAQ at ?http://www.tux.org/lkml/