Skip to contentSkip to conversation

scripts: headers_install.sh: Normalize __ASSEMBLY__ to __ASSEMBLER__

PATCH Superseded Thomas Weißschuh 5 participants 14 messages Mar 9 – Jul 20 Kbuild

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scripts: headers_install.sh: Normalize __ASSEMBLY__ to __ASSEMBLER__

There is an ongoing effort to replace the usage of __ASSEMBLER__ with __ASSEMBLY__ throughout the kernel tree, see for example commit 287d163322b7 ("arm64: Replace __ASSEMBLY__ with __ASSEMBLER__ in non-uapi headers"). The latter is automatically provided by all compilers and preprocessors supported by the kernel, so the explicit definitions of __ASSEMBLER__ can be removed.

However the UAPI headers might be used with older (< GCC 3.0) or non-GCC-compatible compilers, which do not define __ASSEMBLY__ automatically. So this migration may brake users.
Also during the migration phase, the UAPI headers will use a mix of *both* __ASSEMBLY__ and __ASSEMBLER__ at the same time, which is ugly.

For now make sure that the exported UAPI headers consistently use __ASSEMBLER__ as before.

---
This should go either through kbuild or asm-generic, I think.

---
 scripts/headers_install.sh | 1 +
 1 file changed, 1 insertion(+)
scripts/headers_install.sh +1 -0
index 9c15e748761c..2f1d1767ca26 100755
@@ -36,6 +36,7 @@ sed -E -e '
 	s/(^|[^a-zA-Z0-9])__packed([^a-zA-Z0-9_]|$)/\1__attribute__((packed))\2/g
 	s/(^|[[:space:](])(inline|asm|volatile)([[:space:](]|$)/\1__\2__\3/g
 	s@#(ifndef|define|endif[[:space:]]*/[*])[[:space:]]*_UAPI@#\1 @
+	s/__ASSEMBLY__/__ASSEMBLER__/g
 ' $INFILE > $TMPFILE || exit 1
 
 scripts/unifdef -U__KERNEL__ -D__EXPORTED_HEADERS__ $TMPFILE > $OUTFILE

---
base-commit: 6de23f81a5e08be8fbf5e8d7e9febc72a5b5f27f
change-id: 20260302-uapi-assembly-0bb7213b41f1

Best regards,

Signature · 1 line
Thomas Weißschuh <[email protected]>
#1 lore raw
Quoted 2 lines · Thomas Weißschuh

There is an ongoing effort to replace the usage of __ASSEMBLER__ with __ASSEMBLY__ throughout the kernel tree, see for example

I think __ASSEMBLER__ and __ASSEMBLY__ are swapped here?

Quoted 7 lines

commit 287d163322b7 ("arm64: Replace __ASSEMBLY__ with __ASSEMBLER__ in non-uapi headers"). The latter is automatically provided by all compilers and preprocessors supported by the kernel, so the explicit definitions of __ASSEMBLER__ can be removed.

However the UAPI headers might be used with older (< GCC 3.0) or non-GCC-compatible compilers, which do not define __ASSEMBLY__

__ASSEMBLER__?

Quoted 1 line

automatically. So this migration may brake users.

It sounds like the "< GCC 3.0" part of that might not be true based on Maciej's research?

https://lore.kernel.org/[email protected]/

Quoted 5 lines

Also during the migration phase, the UAPI headers will use a mix of *both* __ASSEMBLY__ and __ASSEMBLER__ at the same time, which is ugly.

For now make sure that the exported UAPI headers consistently use __ASSEMBLER__ as before.

__ASSEMBLY__?

Quoted 13 lines

---
This should go either through kbuild or asm-generic, I think.

---
 scripts/headers_install.sh | 1 +
 1 file changed, 1 insertion(+)
scripts/headers_install.sh +0 -0
index 9c15e748761c..2f1d1767ca26 100755

scripts/headers_install.sh sed -E -e ' · line 39

Quoted 4 lines
scripts/headers_install.sh +1 -0
@@ -36,6 +36,7 @@ sed -E -e '
 	s/(^|[^a-zA-Z0-9])__packed([^a-zA-Z0-9_]|$)/\1__attribute__((packed))\2/g
 	s/(^|[[:space:](])(inline|asm|volatile)([[:space:](]|$)/\1__\2__\3/g
 	s@#(ifndef|define|endif[[:space:]]*/[*])[[:space:]]*_UAPI@#\1 @
+	s/__ASSEMBLY__/__ASSEMBLER__/g

It seems like this does the opposite of what is intended or am I misunderstanding something here?

Quoted 12 lines
scripts/headers_install.sh +0 -1
 ' $INFILE > $TMPFILE || exit 1
 
 scripts/unifdef -U__KERNEL__ -D__EXPORTED_HEADERS__ $TMPFILE > $OUTFILE
 
---

base-commit: 6de23f81a5e08be8fbf5e8d7e9febc72a5b5f27f
change-id: 20260302-uapi-assembly-0bb7213b41f1

Best regards,

Signature · 1 line
Thomas Weißschuh <[email protected]>
#2 lore raw

Hi Nathan,

sorry for the late response, this seems to have fallen through the cracks.

Quoted 5 lines · Nathan Chancellor
Quoted 2 lines · Thomas Weißschuh

There is an ongoing effort to replace the usage of __ASSEMBLER__ with __ASSEMBLY__ throughout the kernel tree, see for example

I think __ASSEMBLER__ and __ASSEMBLY__ are swapped here?

Indeed.

(Also all the other cases)

(...)

Quoted 6 lines
Quoted 1 line

automatically. So this migration may brake users.

It sounds like the "< GCC 3.0" part of that might not be true based on Maciej's research?

https://lore.kernel.org/[email protected]/

Yes, indeed. In my opinion the consistency aspect is still sufficient to have this change. What do you think?

(...)

Thomas

#3 lore raw
Quoted 8 lines · Thomas Weißschuh
Quoted 4 lines · Nathan Chancellor

It sounds like the "< GCC 3.0" part of that might not be true based on Maciej's research?

https://lore.kernel.org/[email protected]/

Yes, indeed. In my opinion the consistency aspect is still sufficient to have this change. What do you think?

Yes, I think so. Will you keep it as going from __ASSEMBLY__ to __ASSEMBLER__? It probably makes more sense that way given there should be no regressions on the compiler side and that is the intended end result?

Cheers,
Nathan

#4 lore raw
Quoted 7 lines · Nathan Chancellor
Quoted 6 lines · Thomas Weißschuh
Quoted 4 lines · Nathan Chancellor

It sounds like the "< GCC 3.0" part of that might not be true based on Maciej's research?

https://lore.kernel.org/[email protected]/

Quoted 7 lines
Quoted 2 lines

Yes, indeed. In my opinion the consistency aspect is still sufficient to have this change. What do you think?

Yes, I think so. Will you keep it as going from __ASSEMBLY__ to __ASSEMBLER__? It probably makes more sense that way given there should be no regressions on the compiler side and that is the intended end result?

I would have stuck to the old name '__ASSEMBLY__', just for robustness and because we are late in the cycle.
Then we can switch it early in the next cycle.

Thomas

maintainer
#5 lore raw
Quoted 11 lines · Thomas Weißschuh
Quoted 10 lines · Nathan Chancellor
Quoted 8 lines · Thomas Weißschuh
Quoted 4 lines · Nathan Chancellor

It sounds like the "< GCC 3.0" part of that might not be true based on Maciej's research?

https://lore.kernel.org/[email protected]/

Yes, indeed. In my opinion the consistency aspect is still sufficient to have this change. What do you think?

Quoted 8 lines
Quoted 4 lines

Yes, I think so. Will you keep it as going from __ASSEMBLY__ to __ASSEMBLER__? It probably makes more sense that way given there should be no regressions on the compiler side and that is the intended end result?

I would have stuck to the old name '__ASSEMBLY__', just for robustness and because we are late in the cycle.
Then we can switch it early in the next cycle.

What's the state with this? Shall this show up in linux-next early this cycle?

Signature · 1 line
Nicolas
#6 lore raw
Quoted 17 lines · Nicolas Schier
Quoted 16 lines · Thomas Weißschuh
Quoted 14 lines · Nathan Chancellor
Quoted 8 lines · Thomas Weißschuh
Quoted 4 lines · Nathan Chancellor

It sounds like the "< GCC 3.0" part of that might not be true based on Maciej's research?

https://lore.kernel.org/[email protected]/

Yes, indeed. In my opinion the consistency aspect is still sufficient to have this change. What do you think?

Yes, I think so. Will you keep it as going from __ASSEMBLY__ to __ASSEMBLER__? It probably makes more sense that way given there should be no regressions on the compiler side and that is the intended end result?

Quoted 6 lines
Quoted 3 lines

I would have stuck to the old name '__ASSEMBLY__', just for robustness and because we are late in the cycle.
Then we can switch it early in the next cycle.

What's the state with this? Shall this show up in linux-next early this cycle?

This fell off my radar. I think the commit message needs some small updates based on my review upthread but once resent, we should be able to take it when 7.2-rc1 is out?

Signature · 2 lines
Cheers,
Nathan
#7 lore raw
In reply to Thomas Weißschuh
Quoted 10 lines · Thomas Weißschuh

There is an ongoing effort to replace the usage of __ASSEMBLER__ with __ASSEMBLY__ throughout the kernel tree, see for example commit 287d163322b7 ("arm64: Replace __ASSEMBLY__ with __ASSEMBLER__ in non-uapi headers"). The latter is automatically provided by all compilers and preprocessors supported by the kernel, so the explicit definitions of __ASSEMBLER__ can be removed.

However the UAPI headers might be used with older (< GCC 3.0) or non-GCC-compatible compilers, which do not define __ASSEMBLY__ automatically.

Hi!

I just had a try with gcc 2.95.4 from a Debian Woody installation, and it defines __ASSEMBLER__ automatically when compiling *.S files, i.e. gcc 2.95 does not seem to be a problem. So can you point me to a real case where someone tried to use a user space compiler where __ASSEMBLER__ was not defined automatically? Otherwise, I think this patch could be reverted again.

Thanks,
Thomas

Quoted 27 lines

So this migration may brake users.
Also during the migration phase, the UAPI headers will use a mix of *both* __ASSEMBLY__ and __ASSEMBLER__ at the same time, which is ugly.

For now make sure that the exported UAPI headers consistently use __ASSEMBLER__ as before.

---
This should go either through kbuild or asm-generic, I think.

---
  scripts/headers_install.sh | 1 +
  1 file changed, 1 insertion(+)
scripts/headers_install.sh +1 -0
index 9c15e748761c..2f1d1767ca26 100755
@@ -36,6 +36,7 @@ sed -E -e '
  	s/(^|[^a-zA-Z0-9])__packed([^a-zA-Z0-9_]|$)/\1__attribute__((packed))\2/g
  	s/(^|[[:space:](])(inline|asm|volatile)([[:space:](]|$)/\1__\2__\3/g
  	s@#(ifndef|define|endif[[:space:]]*/[*])[[:space:]]*_UAPI@#\1 @
+	s/__ASSEMBLY__/__ASSEMBLER__/g
  ' $INFILE > $TMPFILE || exit 1
 
  scripts/unifdef -U__KERNEL__ -D__EXPORTED_HEADERS__ $TMPFILE > $OUTFILE
#8 lore raw

Hi Thomas,

Quoted 12 lines · Thomas Huth
Quoted 10 lines · Thomas Weißschuh

There is an ongoing effort to replace the usage of __ASSEMBLER__ with __ASSEMBLY__ throughout the kernel tree, see for example commit 287d163322b7 ("arm64: Replace __ASSEMBLY__ with __ASSEMBLER__ in non-uapi headers"). The latter is automatically provided by all compilers and preprocessors supported by the kernel, so the explicit definitions of __ASSEMBLER__ can be removed.

However the UAPI headers might be used with older (< GCC 3.0) or non-GCC-compatible compilers, which do not define __ASSEMBLY__ automatically.

Quoted 6 lines

I just had a try with gcc 2.95.4 from a Debian Woody installation, and it defines __ASSEMBLER__ automatically when compiling *.S files, i.e. gcc 2.95 does not seem to be a problem. So can you point me to a real case where someone tried to use a user space compiler where __ASSEMBLER__ was not defined automatically? Otherwise, I think this patch could be reverted again.

I don't have a specific case I can point you to. My goal was consistency. Therefore I am against reverting the patch as long as both __ASSEMBLER__ and __ASSEMBLY__ are used in the UAPI headers. If we want to switch to __ASSEMBLER__ for the UAPI headers today, we should instead invert the logic of this patch to consistently use it everywhere. After all UAPI headers are migrated, the normalization can then be removed.

Thomas

Quoted 27 lines
Quoted 26 lines

So this migration may brake users.
Also during the migration phase, the UAPI headers will use a mix of *both* __ASSEMBLY__ and __ASSEMBLER__ at the same time, which is ugly.

For now make sure that the exported UAPI headers consistently use __ASSEMBLER__ as before.

---
This should go either through kbuild or asm-generic, I think.

---
  scripts/headers_install.sh | 1 +
  1 file changed, 1 insertion(+)
scripts/headers_install.sh +1 -0
index 9c15e748761c..2f1d1767ca26 100755
@@ -36,6 +36,7 @@ sed -E -e '
  	s/(^|[^a-zA-Z0-9])__packed([^a-zA-Z0-9_]|$)/\1__attribute__((packed))\2/g
  	s/(^|[[:space:](])(inline|asm|volatile)([[:space:](]|$)/\1__\2__\3/g
  	s@#(ifndef|define|endif[[:space:]]*/[*])[[:space:]]*_UAPI@#\1 @
+	s/__ASSEMBLY__/__ASSEMBLER__/g
  ' $INFILE > $TMPFILE || exit 1
  scripts/unifdef -U__KERNEL__ -D__EXPORTED_HEADERS__ $TMPFILE > $OUTFILE
#9 lore raw
Quoted 11 lines · Thomas Weißschuh
Quoted 10 lines
Quoted 3 lines

However the UAPI headers might be used with older (< GCC 3.0) or non-GCC-compatible compilers, which do not define __ASSEMBLY__ automatically.

I just had a try with gcc 2.95.4 from a Debian Woody installation, and it defines __ASSEMBLER__ automatically when compiling *.S files, i.e. gcc 2.95 does not seem to be a problem. So can you point me to a real case where someone tried to use a user space compiler where __ASSEMBLER__ was not defined automatically? Otherwise, I think this patch could be reverted again.

Quoted 7 lines

I don't have a specific case I can point you to. My goal was consistency. Therefore I am against reverting the patch as long as both __ASSEMBLER__ and __ASSEMBLY__ are used in the UAPI headers. If we want to switch to __ASSEMBLER__ for the UAPI headers today, we should instead invert the logic of this patch to consistently use it everywhere. After all UAPI headers are migrated, the normalization can then be removed.

I believe Thomas specifically refers to the mention of the alleged
shortcoming of pre-3.0 GCC, which we've since verified not to be true, as quoted elsewhere in this thread, so the note needs to be dropped in a respin.

Maciej

#10 lore raw
Quoted 21 lines · Maciej W. Rozycki
Quoted 11 lines · Thomas Weißschuh
Quoted 10 lines
Quoted 3 lines

However the UAPI headers might be used with older (< GCC 3.0) or non-GCC-compatible compilers, which do not define __ASSEMBLY__ automatically.

I just had a try with gcc 2.95.4 from a Debian Woody installation, and it defines __ASSEMBLER__ automatically when compiling *.S files, i.e. gcc 2.95 does not seem to be a problem. So can you point me to a real case where someone tried to use a user space compiler where __ASSEMBLER__ was not defined automatically? Otherwise, I think this patch could be reverted again.

Quoted 7 lines

I don't have a specific case I can point you to. My goal was consistency. Therefore I am against reverting the patch as long as both __ASSEMBLER__ and __ASSEMBLY__ are used in the UAPI headers. If we want to switch to __ASSEMBLER__ for the UAPI headers today, we should instead invert the logic of this patch to consistently use it everywhere. After all UAPI headers are migrated, the normalization can then be removed.

Quoted 4 lines

I believe Thomas specifically refers to the mention of the alleged
shortcoming of pre-3.0 GCC, which we've since verified not to be true, as quoted elsewhere in this thread, so the note needs to be dropped in a respin.

It *was* dropped in a respin[0], which is the patch that got applied.

[0] https://lore.kernel.org/lkml/[email protected]/

#11 lore raw
Quoted 8 lines · Thomas Weißschuh
Quoted 8 lines
Quoted 7 lines

I don't have a specific case I can point you to. My goal was consistency. Therefore I am against reverting the patch as long as both __ASSEMBLER__ and __ASSEMBLY__ are used in the UAPI headers. If we want to switch to __ASSEMBLER__ for the UAPI headers today, we should instead invert the logic of this patch to consistently use it everywhere. After all UAPI headers are migrated, the normalization can then be removed.

Quoted 6 lines
Quoted 4 lines

I believe Thomas specifically refers to the mention of the alleged
shortcoming of pre-3.0 GCC, which we've since verified not to be true, as quoted elsewhere in this thread, so the note needs to be dropped in a respin.

It *was* dropped in a respin[0], which is the patch that got applied.

Ah, OK. I didn't get a match on the respin since it changed the subject.

Maciej

#12 lore raw
In reply to Thomas Weißschuh
Quoted 22 lines · Thomas Weißschuh

Hi Thomas,

Quoted 12 lines · Thomas Huth
Quoted 10 lines · Thomas Weißschuh

There is an ongoing effort to replace the usage of __ASSEMBLER__ with __ASSEMBLY__ throughout the kernel tree, see for example commit 287d163322b7 ("arm64: Replace __ASSEMBLY__ with __ASSEMBLER__ in non-uapi headers"). The latter is automatically provided by all compilers and preprocessors supported by the kernel, so the explicit definitions of __ASSEMBLER__ can be removed.

However the UAPI headers might be used with older (< GCC 3.0) or non-GCC-compatible compilers, which do not define __ASSEMBLY__ automatically.

Quoted 6 lines

I just had a try with gcc 2.95.4 from a Debian Woody installation, and it defines __ASSEMBLER__ automatically when compiling *.S files, i.e. gcc 2.95 does not seem to be a problem. So can you point me to a real case where someone tried to use a user space compiler where __ASSEMBLER__ was not defined automatically? Otherwise, I think this patch could be reverted again.

Quoted 3 lines

I don't have a specific case I can point you to. My goal was consistency. Therefore I am against reverting the patch as long as both __ASSEMBLER__ and __ASSEMBLY__ are used in the UAPI headers.

I've got patches for all files ready and posted them a couple of times already - the problem is, some maintainers are not responsive / ignoring me ... so I'm afraid but I guess we'll be in this inconsistent state for a little bit longer...

Quoted 4 lines

If we want to switch to __ASSEMBLER__ for the UAPI headers today, we should instead invert the logic of this patch to consistently use it everywhere. After all UAPI headers are migrated, the normalization can then be removed.

That sounds like the better idea to me. Could you maybe send a patch, or want me to do it?

Thanks,
Thomas

#13 lore raw
Quoted 21 lines · Thomas Huth
Quoted 20 lines · Thomas Weißschuh
Quoted 18 lines · Thomas Huth
Quoted 10 lines · Thomas Weißschuh

There is an ongoing effort to replace the usage of __ASSEMBLER__ with __ASSEMBLY__ throughout the kernel tree, see for example commit 287d163322b7 ("arm64: Replace __ASSEMBLY__ with __ASSEMBLER__ in non-uapi headers"). The latter is automatically provided by all compilers and preprocessors supported by the kernel, so the explicit definitions of __ASSEMBLER__ can be removed.

However the UAPI headers might be used with older (< GCC 3.0) or non-GCC-compatible compilers, which do not define __ASSEMBLY__ automatically.

I just had a try with gcc 2.95.4 from a Debian Woody installation, and it defines __ASSEMBLER__ automatically when compiling *.S files, i.e. gcc 2.95 does not seem to be a problem. So can you point me to a real case where someone tried to use a user space compiler where __ASSEMBLER__ was not defined automatically? Otherwise, I think this patch could be reverted again.

Quoted 8 lines
Quoted 3 lines

I don't have a specific case I can point you to. My goal was consistency. Therefore I am against reverting the patch as long as both __ASSEMBLER__ and __ASSEMBLY__ are used in the UAPI headers.

I've got patches for all files ready and posted them a couple of times already - the problem is, some maintainers are not responsive / ignoring me ... so I'm afraid but I guess we'll be in this inconsistent state for a little bit longer...

Yeah, this is how these things usually go...

Quoted 6 lines
Quoted 4 lines

If we want to switch to __ASSEMBLER__ for the UAPI headers today, we should instead invert the logic of this patch to consistently use it everywhere. After all UAPI headers are migrated, the normalization can then be removed.

That sounds like the better idea to me. Could you maybe send a patch, or want me to do it?

As you are the one driving this effort, it would be great if you could send the patch. If the patch would make it into v7.3 I am also fine with merging both patches into one if the kbuild maintainers prefer.

Thomas