Skip to contentSkip to conversation

util/cutil: Allow relocatable install with prefix /

PATCH In review Bin Meng 2 participants 2 messages Jan 23, 2024 – Jan 24, 2024

lore
Share & tools
lore

Bin Meng

author
#0 lore raw

PATCH 1/1 util/cutil: Allow relocatable install with prefix /

When configuring QEMU with --prefix=/, the generated QEMU executables can't be relocated to other directories. Add an additional test logic in starts_with_prefix() to handle this.

---

 util/cutils.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
util/cutils.c +2 -1
index 42364039a5..676bd757ba 100644
@@ -1021,7 +1021,8 @@ static inline bool starts_with_prefix(const char *dir)
 #pragma GCC diagnostic ignored "-Warray-bounds="
 #endif
     return !memcmp(dir, CONFIG_PREFIX, prefix_len) &&
-        (!dir[prefix_len] || G_IS_DIR_SEPARATOR(dir[prefix_len]));
+        (!dir[prefix_len] || G_IS_DIR_SEPARATOR(dir[prefix_len]) ||
+         !strcmp(CONFIG_PREFIX, "/"));
 #pragma GCC diagnostic pop
 }
 
Signature · 1 line
2.34.1
#1 lore raw
Quoted 3 lines · Bin Meng

When configuring QEMU with --prefix=/, the generated QEMU executables can't be relocated to other directories. Add an additional test logic in starts_with_prefix() to handle this.

What about setting "" as CONFIG_PREFIX in Meson when --prefix=/ ?

CONFIG_PREFIX is expected not to have the ending slash. --prefix needs the ending slash for the root, but it is just a quirk of Meson, which is probably better to be handled in Meson, too.

Regards,
Akihiko Odaki