Skip to contentSkip to conversation

Fix build for less common build directories names

PATCH Applied Stefan Weil 5 participants 12 messages Oct 13, 2016 – Oct 28, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix build for less common build directories names

scripts/tracetool generates a C preprocessor macro from the name of the build directory. Any characters which are possible in a directory name but not allowed in a macro name must be substituted, otherwise builds will fail.

---

I had problems with a build directory of the form "host,variant". Is this fix needed for stable, too?

Regards
Stefan W.

 scripts/tracetool.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/tracetool.py +1 -1
index 629b259..fe9c9e9 100755
@@ -70,7 +70,7 @@ def make_group_name(filename):
 
     if dirname == "":
         return "common"
-    return re.sub(r"/|-", "_", dirname)
+    return re.sub(r"[^A-Za-z0-9]", "_", dirname)
 
 def main(args):
     global _SCRIPT
Signature · 1 line
2.1.4
#1 lore raw
Quoted 10 lines · Stefan Weil

scripts/tracetool generates a C preprocessor macro from the name of the build directory. Any characters which are possible in a directory name but not allowed in a macro name must be substituted, otherwise builds will fail.

---

I had problems with a build directory of the form "host,variant". Is this fix needed for stable, too?

Why does it need to care about the build directory name at all? Ideally builds should be entirely deterministically reproducible whatever the path to the source or build directory names is...

thanks
-- PMM

#2 lore raw
Quoted 9 lines · Peter Maydell
Quoted 8 lines · Stefan Weil

scripts/tracetool generates a C preprocessor macro from the name of the build directory. Any characters which are possible in a directory name but not allowed in a macro name must be substituted, otherwise builds will fail.

---

Quoted 6 lines
Quoted 2 lines

I had problems with a build directory of the form "host,variant". Is this fix needed for stable, too?

Why does it need to care about the build directory name at all? Ideally builds should be entirely deterministically reproducible whatever the path to the source or build directory names is...

It's trying to construct the relative path from the source directory to a trace-events file (inside the source directory). This is used so that block/trace-event macros have BLOCK in their name while net/trace-events have NET, etc.

It does not care about the build directory or source directory path per se. Therefore deterministic builds shouldn't be a problem if the code is working correctly ;).

Stefan

#3 lore raw
Quoted 8 lines · Stefan Hajnoczi
Quoted 3 lines

Why does it need to care about the build directory name at all? Ideally builds should be entirely deterministically reproducible whatever the path to the source or build directory names is...

It's trying to construct the relative path from the source directory to a trace-events file (inside the source directory). This is used so that block/trace-event macros have BLOCK in their name while net/trace-events have NET, etc.

But Stefan (Weil) is right, it's actually including the path to the build directory if you're building with objdir!=srcdir. It should not need that.

Paolo

#4 lore raw
In reply to Stefan Weil
Quoted 22 lines · Stefan Weil

scripts/tracetool generates a C preprocessor macro from the name of the build directory. Any characters which are possible in a directory name but not allowed in a macro name must be substituted, otherwise builds will fail.

---

I had problems with a build directory of the form "host,variant". Is this fix needed for stable, too?

Regards
Stefan W.

 scripts/tracetool.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/tracetool.py +0 -0
index 629b259..fe9c9e9 100755

scripts/tracetool.py def make_group_name(filename): · line 73

Quoted 5 lines
scripts/tracetool.py +1 -1
@@ -70,7 +70,7 @@ def make_group_name(filename):
 
     if dirname == "":
         return "common"
-    return re.sub(r"/|-", "_", dirname)
+    return re.sub(r"[^A-Za-z0-9]", "_", dirname)

dirname should only contain QEMU source tree subdirectory paths (e.g. hw/net). How did you get a comma in there?

I tried an out-of-tree build in a directory called 'a,b' but it doesn't trigger the issue.

I'd like to understand how to reproduce the problem in case I missed something.

Stefan

#5 lore raw
Quoted 10 lines · Stefan Hajnoczi

dirname should only contain QEMU source tree subdirectory paths (e.g. hw/net). How did you get a comma in there?

I tried an out-of-tree build in a directory called 'a,b' but it doesn't trigger the issue.

I'd like to understand how to reproduce the problem in case I missed something.

Stefan

I can reproduce it like this from the QEMU base directory:

$ mkdir a,b
$ cd a,b
$ ../configure
[...]
$ make
[...]
make: *** [trace/generated-tracers.o] Error 1
$ head trace/generated-tracers.h
/* This file is autogenerated by tracetool, do not edit. */

#ifndef TRACE_A,B_GENERATED_TRACERS_H
#define TRACE_A,B_GENERATED_TRACERS_H

Stefan

#6 lore raw
Quoted 24 lines · Stefan Weil
Quoted 10 lines · Stefan Hajnoczi

dirname should only contain QEMU source tree subdirectory paths (e.g. hw/net). How did you get a comma in there?

I tried an out-of-tree build in a directory called 'a,b' but it doesn't trigger the issue.

I'd like to understand how to reproduce the problem in case I missed something.

Stefan

I can reproduce it like this from the QEMU base directory:

$ mkdir a,b
$ cd a,b
$ ../configure
[...]
$ make
[...]
make: *** [trace/generated-tracers.o] Error 1
$ head trace/generated-tracers.h
/* This file is autogenerated by tracetool, do not edit. */
Quoted 2 lines

#ifndef TRACE_A,B_GENERATED_TRACERS_H
#define TRACE_A,B_GENERATED_TRACERS_H

Interesting! I missed it because my a,b directory was not inside the source directory.

Stefan

#7 lore raw
In reply to Stefan Weil
Quoted 4 lines · Stefan Weil

scripts/tracetool generates a C preprocessor macro from the name of the build directory. Any characters which are possible in a directory name but not allowed in a macro name must be substituted, otherwise builds will fail.

Applied to -trivial, thank you!

/mjt

#8 lore raw
Quoted 7 lines · Michael Tokarev
Quoted 4 lines · Stefan Weil

scripts/tracetool generates a C preprocessor macro from the name of the build directory. Any characters which are possible in a directory name but not allowed in a macro name must be substituted, otherwise builds will fail.

Applied to -trivial, thank you!

Consensus on this and the other thread seemed to be that we should just fix the bug where tracetool is putting the build directory name into symbols rather than working around that...

thanks
-- PMM

#9 lore raw

Am 16.10.2016 um 21:04 schrieb Peter Maydell:

Quoted 9 lines · Michael Tokarev
Quoted 7 lines
Quoted 4 lines · Stefan Weil

scripts/tracetool generates a C preprocessor macro from the name of the build directory. Any characters which are possible in a directory name but not allowed in a macro name must be substituted, otherwise builds will fail.

Applied to -trivial, thank you!

Quoted 8 lines

Consensus on this and the other thread seemed to be that we should just fix the bug where tracetool is putting the build directory name into symbols rather than working around that...

thanks
-- PMM

IMHO the patch can be applied nevertheless, as it uses a clearer regular expression for characters allowed in macro names (not one that is specific for the current QEMU code).

Stefan

#10 lore raw
Quoted 15 lines · Stefan Weil

Am 16.10.2016 um 21:04 schrieb Peter Maydell:

Quoted 14 lines · Michael Tokarev
Quoted 7 lines
Quoted 4 lines · Stefan Weil

scripts/tracetool generates a C preprocessor macro from the name of the build directory. Any characters which are possible in a directory name but not allowed in a macro name must be substituted, otherwise builds will fail.

Applied to -trivial, thank you!

Consensus on this and the other thread seemed to be that we should just fix the bug where tracetool is putting the build directory name into symbols rather than working around that...

Quoted 6 lines
Quoted 2 lines

thanks
-- PMM

IMHO the patch can be applied nevertheless, as it uses a clearer regular expression for characters allowed in macro names (not one that is specific for the current QEMU code).

So, what's the thing here?

Once again I hit this bug today, when my usual build environment doesn't work:

./trace/generated-tracers.h:3:15: error: extra tokens at end of #ifndef directive [-Werror]

 #ifndef TRACE_.B64_GENERATED_TRACERS_H
               ^

and this patch fixes the issue for me.

Thanks,

/mjt

#11 lore raw
Quoted 16 lines · Michael Tokarev
Quoted 15 lines · Stefan Weil

Am 16.10.2016 um 21:04 schrieb Peter Maydell:

Quoted 14 lines · Michael Tokarev
Quoted 7 lines
Quoted 4 lines · Stefan Weil

scripts/tracetool generates a C preprocessor macro from the name of the build directory. Any characters which are possible in a directory name but not allowed in a macro name must be substituted, otherwise builds will fail.

Applied to -trivial, thank you!

Consensus on this and the other thread seemed to be that we should just fix the bug where tracetool is putting the build directory name into symbols rather than working around that...

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

thanks
-- PMM

IMHO the patch can be applied nevertheless, as it uses a clearer regular expression for characters allowed in macro names (not one that is specific for the current QEMU code).

So, what's the thing here?

I think we concluded that the underlying problem was a bit tricky to fix and we should apply this workaround in the meantime.

thanks
-- PMM