xen: always consider '/' as a division in assembly
PATCH 1/1 xen: always consider '/' as a division in assembly
GNU assembler will consider '/' as the start of comment marker on some platforms. This is incorrect with Xen's usage, which does use '/' in assembly files as a mathematical operator.
The behavior of the assembler can be altered by passing the --divide option; unconditionally pass this option when available to force the expected behavior.
--- xen/Makefile | 5 +++++ 1 file changed, 5 insertions(+)
xen/Makefile +5 -0
@@ -405,6 +405,11 @@ $(call cc-option-add,CFLAGS,CC,-Winit-self) CFLAGS += -pipe -D__XEN__ -include $(srctree)/include/xen/config.h CFLAGS-$(CONFIG_DEBUG_INFO) += -g +# The GNU assembler will interpret '/' as a comment start marker instead of a +# divide on some platforms. Pass --divide when when available to signal '/' is +# always used as an operator in assembly. +$(call cc-option-add,CFLAGS,CC,-Wa$$(comma)--divide) + ifneq ($(CONFIG_CC_IS_CLANG),y) # Clang doesn't understand this command line argument, and doesn't appear to # have a suitable alternative. The resulting compiled binary does function,
Signature · 1 line
2.51.0
Quoted 7 lines · Roger Pau Monne
GNU assembler will consider '/' as the start of comment marker on some platforms. This is incorrect with Xen's usage, which does use '/' in assembly files as a mathematical operator.
The behavior of the assembler can be altered by passing the --divide option; unconditionally pass this option when available to force the expected behavior.
I'm fine with this in principle, but I wonder: What about Clang? If it's properly compatible, it ought to also take '/' as a comment char for those same targets (in particular for the plain "x86_64-elf" one). According to godbolt it can't deal with -Wa,--divide, yet there I also can't control what exact target the toolchain supports (i.e. this may be only a weak indication of lack of support / compatibility).
xen/Makefile $(call cc-option-add,CFLAGS,CC,-Winit-self) · line 409
Quoted 8 lines
xen/Makefile +2
-0@@ -405,6 +405,11 @@ $(call cc-option-add,CFLAGS,CC,-Winit-self) CFLAGS += -pipe -D__XEN__ -include $(srctree)/include/xen/config.h CFLAGS-$(CONFIG_DEBUG_INFO) += -g +# The GNU assembler will interpret '/' as a comment start marker instead of a +# divide on some platforms.
Could I talk you into s/on some platforms/for some ELF targets/ ?
A more fundamental question is: Do we really mean to support (allow) building with arbitrary-target toolchains? There are other subtle differences, which may be hard to evaluate as to them possibly affecting the Xen build.
xen/Makefile $(call cc-option-add,CFLAGS,CC,-Winit-self) · line 411
Quoted 3 lines
xen/Makefile +2
-0Pass --divide when when available to signal '/' is +# always used as an operator in assembly. +$(call cc-option-add,CFLAGS,CC,-Wa$$(comma)--divide)
I don't think this should be done here: --divide is an x86-specific option.
Jan
Quoted 9 lines · Jan Beulich
Quoted 7 lines · Roger Pau Monne
GNU assembler will consider '/' as the start of comment marker on some platforms. This is incorrect with Xen's usage, which does use '/' in assembly files as a mathematical operator.
The behavior of the assembler can be altered by passing the --divide option; unconditionally pass this option when available to force the expected behavior.
Quoted 6 lines
I'm fine with this in principle, but I wonder: What about Clang? If it's properly compatible, it ought to also take '/' as a comment char for those same targets (in particular for the plain "x86_64-elf" one). According to godbolt it can't deal with -Wa,--divide, yet there I also can't control what exact target the toolchain supports (i.e. this may be only a weak indication of lack of support / compatibility).
Hm, I'm unsure I can get such a Clang build to properly test it. Note the checking for the presence of the option would also be done in Clang. I would like to think if Clang integrated assembler has this behavior the option to select our expected behavior will also be --divide. I think that's the best I can do ATM.
Quoted 10 lines
xen/Makefile $(call cc-option-add,CFLAGS,CC,-Winit-self) · line 409
Quoted 8 lines
xen/Makefile +2
-0@@ -405,6 +405,11 @@ $(call cc-option-add,CFLAGS,CC,-Winit-self) CFLAGS += -pipe -D__XEN__ -include $(srctree)/include/xen/config.h CFLAGS-$(CONFIG_DEBUG_INFO) += -g +# The GNU assembler will interpret '/' as a comment start marker instead of a +# divide on some platforms.Could I talk you into s/on some platforms/for some ELF targets/ ?
Yes, that's fine IMO.
Quoted 4 lines
A more fundamental question is: Do we really mean to support (allow) building with arbitrary-target toolchains? There are other subtle differences, which may be hard to evaluate as to them possibly affecting the Xen build.
Hm, TBH I wasn't aware of such subtle and annoying differences until today, so I'm not sure what to reply here. I haven't tested the x86 image yet, as I'm still attempting to resolve some non-POSIX options usage in check-endbr.sh.
We might want to state which ELF targets we do explicitly support for production usage. TBH I doubt anyone would use a Darwin build for production.
Quoted 6 lines
xen/Makefile $(call cc-option-add,CFLAGS,CC,-Winit-self) · line 411
Quoted 3 lines
xen/Makefile +2
-0Pass --divide when when available to signal '/' is +# always used as an operator in assembly. +$(call cc-option-add,CFLAGS,CC,-Wa$$(comma)--divide)I don't think this should be done here: --divide is an x86-specific option.
Oh, that wasn't clear from the output of as. I can make it x86-specific then. However, is there any chance of this behavior escaping outside of x86, and hence would we like to ensure this behavior on all possible arches?
Or is it possible that other arches re-use the --divide option for some other functionality?
Thanks, Roger.
Quoted 9 lines · Roger Pau Monné
Quoted 7 lines · Jan Beulich
Quoted 3 lines · Roger Pau Monne
Pass --divide when when available to signal '/' is
+# always used as an operator in assembly. +$(call cc-option-add,CFLAGS,CC,-Wa$$(comma)--divide)I don't think this should be done here: --divide is an x86-specific option.
Quoted 7 lines
Oh, that wasn't clear from the output of as. I can make it x86-specific then. However, is there any chance of this behavior escaping outside of x86, and hence would we like to ensure this behavior on all possible arches?
Or is it possible that other arches re-use the --divide option for some other functionality?
It is equally possible for that to happen (if some target needs to support '/' as a comment char) as it is for such a target to then use an entirely different command line option. Furthermore, --divide may mean something else on another arch.
Jan
Hi Roger,
Quoted 9 lines · Roger Pau Monne
GNU assembler will consider '/' as the start of comment marker on some platforms. This is incorrect with Xen's usage, which does use '/' in assembly files as a mathematical operator.
The behavior of the assembler can be altered by passing the --divide option; unconditionally pass this option when available to force the expected behavior.
This is solving the issue and I can build for arm with what and further for x86 on mac os but it fails on check-endbr.sh:
/bin/sh ../tools/check-endbr.sh xen-syms
stat: illegal option -- c
Cheers
Bertrand
Quoted 26 lines
Reported-by Jan Beulich <[email protected]>Signed-off-by Roger Pau Monné <[email protected]>---
xen/Makefile | 5 +++++1 file changed, 5 insertions(+)xen/Makefile +0
-0@@ -405,6 +405,11 @@ $(call cc-option-add,CFLAGS,CC,-Winit-self)CFLAGS += -pipe -D__XEN__ -include $(srctree)/include/xen/config.h CFLAGS-$(CONFIG_DEBUG_INFO) += -g
xen/Makefile +5
-0+# The GNU assembler will interpret '/' as a comment start marker instead of a +# divide on some platforms. Pass --divide when when available to signal '/' is +# always used as an operator in assembly. +$(call cc-option-add,CFLAGS,CC,-Wa$$(comma)--divide) +ifneq ($(CONFIG_CC_IS_CLANG),y)
# Clang doesn't understand this command line argument, and doesn't appear to# have a suitable alternative. The resulting compiled binary does function,Signature · 1 line
2.51.0
Quoted 12 lines · Bertrand Marquis
Hi Roger,
Quoted 9 lines · Roger Pau Monne
GNU assembler will consider '/' as the start of comment marker on some platforms. This is incorrect with Xen's usage, which does use '/' in assembly files as a mathematical operator.
The behavior of the assembler can be altered by passing the --divide option; unconditionally pass this option when available to force the expected behavior.
Quoted 5 lines
This is solving the issue and I can build for arm with what and further for x86 on mac os but it fails on
check-endbr.sh:
/bin/sh../tools/check-endbr.shxen-syms
stat: illegal option -- c
Yeah, I know. I've fixed the stat issue, but there's a further one about an illegal bit sequence in grep. I'm looking into that.
Thanks, Roger.
Hi Roger
Quoted 15 lines · Roger Pau Monné
Quoted 12 lines · Bertrand Marquis
Hi Roger,
Quoted 9 lines · Roger Pau Monne
GNU assembler will consider '/' as the start of comment marker on some platforms. This is incorrect with Xen's usage, which does use '/' in assembly files as a mathematical operator.
The behavior of the assembler can be altered by passing the --divide option; unconditionally pass this option when available to force the expected behavior.
Quoted 8 lines
Quoted 5 lines
This is solving the issue and I can build for arm with what and further for x86 on mac os but it fails on
check-endbr.sh:
/bin/sh../tools/check-endbr.shxen-syms
stat: illegal option -- cYeah, I know. I've fixed the stat issue, but there's a further one about an illegal bit sequence in grep. I'm looking into that.
LC_ALL=C grep is fixing that one on my side
with that and stat -c replaced with wc -c < xx I can fully compile x86 on Mac os.
Cheers
Bertrand
Quoted 2 lines
Thanks, Roger.
Quoted 20 lines · Bertrand Marquis
Hi Roger
Quoted 18 lines · Roger Pau Monné
Quoted 15 lines · Bertrand Marquis
Hi Roger,
Quoted 9 lines · Roger Pau Monne
GNU assembler will consider '/' as the start of comment marker on some platforms. This is incorrect with Xen's usage, which does use '/' in assembly files as a mathematical operator.
The behavior of the assembler can be altered by passing the --divide option; unconditionally pass this option when available to force the expected behavior.
This is solving the issue and I can build for arm with what and further for x86 on mac os but it fails on
check-endbr.sh:
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
/bin/sh../tools/check-endbr.shxen-syms
stat: illegal option -- cYeah, I know. I've fixed the stat issue, but there's a further one about an illegal bit sequence in grep. I'm looking into that.
LC_ALL=C grep is fixing that one on my side
I haven't tested that one yet, but yes, might be a way to solve. Would you like to send the fix for grep?
Quoted 1 line
with that and stat -c replaced with wc -c < xx I can fully compile x86 on Mac os.
Yeah, the problem with using wc is that you have to read the file. I prefer $(($(du <file> |cut -w -f1) << 9)) because that avoids reading the actual data to count.
Thanks, Roger.
Quoted 29 lines · Roger Pau Monné
Quoted 20 lines · Bertrand Marquis
Hi Roger
Quoted 18 lines · Roger Pau Monné
Quoted 15 lines · Bertrand Marquis
Hi Roger,
Quoted 9 lines · Roger Pau Monne
GNU assembler will consider '/' as the start of comment marker on some platforms. This is incorrect with Xen's usage, which does use '/' in assembly files as a mathematical operator.
The behavior of the assembler can be altered by passing the --divide option; unconditionally pass this option when available to force the expected behavior.
This is solving the issue and I can build for arm with what and further for x86 on mac os but it fails on
check-endbr.sh:Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
/bin/sh../tools/check-endbr.shxen-syms
stat: illegal option -- cYeah, I know. I've fixed the stat issue, but there's a further one about an illegal bit sequence in grep. I'm looking into that.
LC_ALL=C grep is fixing that one on my side
Quoted 8 lines
I haven't tested that one yet, but yes, might be a way to solve. Would you like to send the fix for grep?
Quoted 1 line
with that and stat -c replaced with wc -c < xx I can fully compile x86 on Mac os.
Yeah, the problem with using wc is that you have to read the file. I prefer $(($(du <file> |cut -w -f1) << 9)) because that avoids reading the actual data to count.
But shifting by hardcoded 9 doesn't look very portable. The size not being exact may be okay for the purposes here, but wouldn't it then be better to use (standardized) ls output?
Jan
Hi,
Quoted 37 lines · Jan Beulich
Quoted 34 lines · Roger Pau Monné
Quoted 20 lines · Bertrand Marquis
Hi Roger
Quoted 18 lines · Roger Pau Monné
Quoted 15 lines · Bertrand Marquis
Hi Roger,
Quoted 9 lines · Roger Pau Monne
GNU assembler will consider '/' as the start of comment marker on some platforms. This is incorrect with Xen's usage, which does use '/' in assembly files as a mathematical operator.
The behavior of the assembler can be altered by passing the --divide option; unconditionally pass this option when available to force the expected behavior.
This is solving the issue and I can build for arm with what and further for x86 on mac os but it fails on
check-endbr.sh:Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
/bin/sh../tools/check-endbr.shxen-syms
stat: illegal option -- cYeah, I know. I've fixed the stat issue, but there's a further one about an illegal bit sequence in grep. I'm looking into that.
LC_ALL=C grep is fixing that one on my side
I haven't tested that one yet, but yes, might be a way to solve. Would you like to send the fix for grep?
Quoted 1 line
with that and stat -c replaced with wc -c < xx I can fully compile x86 on Mac os.
Quoted 7 lines
Quoted 3 lines
Yeah, the problem with using wc is that you have to read the file. I prefer $(($(du <file> |cut -w -f1) << 9)) because that avoids reading the actual data to count.
But shifting by hardcoded 9 doesn't look very portable. The size not being exact may be okay for the purposes here, but wouldn't it then be better to use (standardized) ls output?
Suggesting this:
wc -c < "$TEXT_BIN"
Bertrand
Hi Roger,
Quoted 31 lines · Roger Pau Monné
Quoted 20 lines · Bertrand Marquis
Hi Roger
Quoted 18 lines · Roger Pau Monné
Quoted 15 lines · Bertrand Marquis
Hi Roger,
Quoted 9 lines · Roger Pau Monne
GNU assembler will consider '/' as the start of comment marker on some platforms. This is incorrect with Xen's usage, which does use '/' in assembly files as a mathematical operator.
The behavior of the assembler can be altered by passing the --divide option; unconditionally pass this option when available to force the expected behavior.
This is solving the issue and I can build for arm with what and further for x86 on mac os but it fails on
check-endbr.sh:Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
/bin/sh../tools/check-endbr.shxen-syms
stat: illegal option -- cYeah, I know. I've fixed the stat issue, but there's a further one about an illegal bit sequence in grep. I'm looking into that.
LC_ALL=C grep is fixing that one on my side
Quoted 8 lines
I haven't tested that one yet, but yes, might be a way to solve. Would you like to send the fix for grep?
Quoted 1 line
with that and stat -c replaced with wc -c < xx I can fully compile x86 on Mac os.
Yeah, the problem with using wc is that you have to read the file. I prefer $(($(du <file> |cut -w -f1) << 9)) because that avoids reading the actual data to count.
Both fixes should be included in the same patch.
Will submit one once we agree on the solution for stat -c. I suggested:
wc -c < "$TEXT_BIN"
Tell me if that works for you.
Cheers
Bertrand
Quoted 2 lines
Thanks, Roger.