Skip to contentSkip to conversation

tcg: Avoid setting tcg_initialize if !CONFIG_TCG

PATCH In review Richard Henderson 7 participants 10 messages Oct 26, 2017 – Oct 30, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tcg: Avoid setting tcg_initialize if !CONFIG_TCG

Fix the build for --disable-tcg.

Fixes 55c3ceef61fcf06fc98ddc752b7cce788ce7680b
---
 target/arm/cpu.c            | 2 ++
 target/i386/cpu.c           | 2 ++
 target/mips/cpu.c           | 2 ++
 target/ppc/translate_init.c | 2 ++
 target/s390x/cpu.c          | 2 ++
 5 files changed, 10 insertions(+)
target/arm/cpu.c +2 -0
index 056284985d..a7f03eabe8 100644
@@ -1760,7 +1760,9 @@ static void arm_cpu_class_init(ObjectClass *oc, void *data)
 #endif
 
     cc->disas_set_info = arm_disas_set_info;
+#ifdef CONFIG_TCG
     cc->tcg_initialize = arm_translate_init;
+#endif
 }
 
 static void cpu_register(const ARMCPUInfo *info)
target/i386/cpu.c +2 -0
index 53ec94ac9b..2f556c0ea3 100644
@@ -4212,7 +4212,9 @@ static void x86_cpu_common_class_init(ObjectClass *oc, void *data)
 #endif
     cc->cpu_exec_enter = x86_cpu_exec_enter;
     cc->cpu_exec_exit = x86_cpu_exec_exit;
+#ifdef CONFIG_TCG
     cc->tcg_initialize = tcg_x86_init;
+#endif
 
     dc->user_creatable = true;
 }
target/mips/cpu.c +2 -0
index 0ae70288dd..80812f3e08 100644
@@ -198,7 +198,9 @@ static void mips_cpu_class_init(ObjectClass *c, void *data)
     cc->vmsd = &vmstate_mips_cpu;
 #endif
     cc->disas_set_info = mips_cpu_disas_set_info;
+#ifdef CONFIG_TCG
     cc->tcg_initialize = mips_tcg_init;
+#endif
 
     cc->gdb_num_core_regs = 73;
     cc->gdb_stop_before_watchpoint = true;
target/ppc/translate_init.c +2 -0
index 13436e4760..61a9552c1c 100644
@@ -10578,7 +10578,9 @@ static void ppc_cpu_class_init(ObjectClass *oc, void *data)
 #ifndef CONFIG_USER_ONLY
     cc->virtio_is_big_endian = ppc_cpu_is_big_endian;
 #endif
+#ifdef CONFIG_TCG
     cc->tcg_initialize = ppc_translate_init;
+#endif
 
     dc->fw_name = "PowerPC,UNKNOWN";
 }
target/s390x/cpu.c +2 -0
index 824dfd6b65..ae3cee91a2 100644
@@ -497,7 +497,9 @@ static void s390_cpu_class_init(ObjectClass *oc, void *data)
 #endif
 #endif
     cc->disas_set_info = s390_cpu_disas_set_info;
+#ifdef CONFIG_TCG
     cc->tcg_initialize = s390x_translate_init;
+#endif
 
     cc->gdb_num_core_regs = S390_NUM_CORE_REGS;
     cc->gdb_core_xml_file = "s390x-core64.xml";
Signature · 1 line
2.13.6
Reviewed-by on v1 1/1
#1 lore raw
Quoted 17 lines · Richard Henderson

Fix the build for --disable-tcg.

Fixes 55c3ceef61fcf06fc98ddc752b7cce788ce7680b
---
 target/arm/cpu.c            | 2 ++
 target/i386/cpu.c           | 2 ++
 target/mips/cpu.c           | 2 ++
 target/ppc/translate_init.c | 2 ++
 target/s390x/cpu.c          | 2 ++
 5 files changed, 10 insertions(+)
target/arm/cpu.c +0 -0
index 056284985d..a7f03eabe8 100644

target/arm/cpu.c static void arm_cpu_class_init(ObjectClass *oc, void *data) · line 1765

Quoted 6 lines
target/arm/cpu.c +2 -0
@@ -1760,7 +1760,9 @@ static void arm_cpu_class_init(ObjectClass *oc, void *data)
 #endif
 
     cc->disas_set_info = arm_disas_set_info;
+#ifdef CONFIG_TCG
     cc->tcg_initialize = arm_translate_init;
+#endif

I'd prefer to have *_translate_init() stubs instead of the #ifdefs, but I guess it's better to fix the build as soon as possible, and worry about eliminating #ifdefs later.

Quoted 62 lines
target/arm/cpu.c +0 -0
 }
 
 static void cpu_register(const ARMCPUInfo *info)
target/i386/cpu.c +2 -0
index 53ec94ac9b..2f556c0ea3 100644
@@ -4212,7 +4212,9 @@ static void x86_cpu_common_class_init(ObjectClass *oc, void *data)
 #endif
     cc->cpu_exec_enter = x86_cpu_exec_enter;
     cc->cpu_exec_exit = x86_cpu_exec_exit;
+#ifdef CONFIG_TCG
     cc->tcg_initialize = tcg_x86_init;
+#endif
 
     dc->user_creatable = true;
 }
target/mips/cpu.c +2 -0
index 0ae70288dd..80812f3e08 100644
@@ -198,7 +198,9 @@ static void mips_cpu_class_init(ObjectClass *c, void *data)
     cc->vmsd = &vmstate_mips_cpu;
 #endif
     cc->disas_set_info = mips_cpu_disas_set_info;
+#ifdef CONFIG_TCG
     cc->tcg_initialize = mips_tcg_init;
+#endif
 
     cc->gdb_num_core_regs = 73;
     cc->gdb_stop_before_watchpoint = true;
target/ppc/translate_init.c +2 -0
index 13436e4760..61a9552c1c 100644
@@ -10578,7 +10578,9 @@ static void ppc_cpu_class_init(ObjectClass *oc, void *data)
 #ifndef CONFIG_USER_ONLY
     cc->virtio_is_big_endian = ppc_cpu_is_big_endian;
 #endif
+#ifdef CONFIG_TCG
     cc->tcg_initialize = ppc_translate_init;
+#endif
 
     dc->fw_name = "PowerPC,UNKNOWN";
 }
target/s390x/cpu.c +2 -0
index 824dfd6b65..ae3cee91a2 100644
@@ -497,7 +497,9 @@ static void s390_cpu_class_init(ObjectClass *oc, void *data)
 #endif
 #endif
     cc->disas_set_info = s390_cpu_disas_set_info;
+#ifdef CONFIG_TCG
     cc->tcg_initialize = s390x_translate_init;
+#endif
 
     cc->gdb_num_core_regs = S390_NUM_CORE_REGS;
     cc->gdb_core_xml_file = "s390x-core64.xml";
Signature · 1 line
2.13.6
Signature · 1 line
Eduardo
Reviewed-by on v1 1/1
#2 lore raw
In reply to Richard Henderson
Quoted 11 lines · Richard Henderson

Fix the build for --disable-tcg.

Fixes 55c3ceef61fcf06fc98ddc752b7cce788ce7680b
---
 target/arm/cpu.c            | 2 ++
 target/i386/cpu.c           | 2 ++
 target/mips/cpu.c           | 2 ++
 target/ppc/translate_init.c | 2 ++
 target/s390x/cpu.c          | 2 ++
 5 files changed, 10 insertions(+)

AFAIK the only target that is so far supposed to work with --disable-tcg is i386. The configure script however lets you try to build without TCG if the host has an alternative accelerator (e.g. KVM), but that build is likely to fail. [ just confirmed this with aarch64 ]

That said, I like that this patch takes care of other targets too.

Thanks,

Emilio

#3 lore raw
Quoted 4 lines · Emilio G. Cota

AFAIK the only target that is so far supposed to work with --disable-tcg is i386. The configure script however lets you try to build without TCG if the host has an alternative accelerator (e.g. KVM), but that build is likely to fail. [ just confirmed this with aarch64 ]

What about s390x?

LINK s390x-softmmu/qemu-system-s390x
exec.o: In function `tlb_reset_dirty_range_all':
exec.c:1118: undefined reference to tlb_reset_dirty' exec.o: In function tcg_commit':
exec.c:2765: undefined reference to cpu_reloading_memory_map' cpus.o: In function tcg_cpu_exec':
cpus.c:1270: undefined reference to `cpu_exec'
cpus.o: In function `qemu_tcg_rr_cpu_thread_fn':
cpus.c:1310: undefined reference to tcg_register_thread' cpus.c:1375: undefined reference to cpu_exec_step_atomic' cpus.o: In function `qemu_tcg_cpu_thread_fn':
cpus.c:1458: undefined reference to tcg_register_thread' cpus.c:1492: undefined reference to cpu_exec_step_atomic' cpus.o: In function `qemu_tcg_init_vcpu':
cpus.c:1679: undefined reference to tcg_region_init' cpus.c:1689: undefined reference to parallel_cpus' target/s390x/cpu.o: In function `s390_cpu_class_init':
target/s390x/cpu.c:500: undefined reference to `s390x_translate_init'
collect2: error: ld returned 1 exit status

#4 lore raw

Oops sent a bit too fast.

Quoted 19 lines · Philippe Mathieu-Daudé
Quoted 4 lines · Emilio G. Cota

AFAIK the only target that is so far supposed to work with --disable-tcg is i386. The configure script however lets you try to build without TCG if the host has an alternative accelerator (e.g. KVM), but that build is likely to fail. [ just confirmed this with aarch64 ]

What about s390x?

LINK s390x-softmmu/qemu-system-s390x
exec.o: In function `tlb_reset_dirty_range_all':
exec.c:1118: undefined reference to tlb_reset_dirty' exec.o: In function tcg_commit':
exec.c:2765: undefined reference to cpu_reloading_memory_map' cpus.o: In function tcg_cpu_exec':
cpus.c:1270: undefined reference to cpu_exec' cpus.o: In function qemu_tcg_rr_cpu_thread_fn':
cpus.c:1310: undefined reference to tcg_register_thread' cpus.c:1375: undefined reference to cpu_exec_step_atomic' cpus.o: In function `qemu_tcg_cpu_thread_fn':

Quoted 8 lines

cpus.c:1458: undefined reference to tcg_register_thread' cpus.c:1492: undefined reference to cpu_exec_step_atomic' cpus.o: In function `qemu_tcg_init_vcpu':
cpus.c:1679: undefined reference to tcg_region_init' cpus.c:1689: undefined reference to parallel_cpus' target/s390x/cpu.o: In function `s390_cpu_class_init':
target/s390x/cpu.c:500: undefined reference to `s390x_translate_init'
collect2: error: ld returned 1 exit status

bisected to:

b11ec7f2e44b285a3967d629b55d1a6970b06787 is the first bad commit commit b11ec7f2e44b285a3967d629b55d1a6970b06787

Author: Yang Zhong <[email protected]>
Date:   Mon Jul 3 18:12:21 2017 +0800

tcg: add CONFIG_TCG guards in headers

Add CONFIG_TCG around TLB-related functions and structure declarations. Some of these functions are defined in ./accel/tcg/cputlb.c, which will not be linked in if TCG is disabled, and have no stubs; therefore, their callers will also be compiled out for --disable-tcg.

#5 lore raw
Quoted 5 lines · Philippe Mathieu-Daudé
Quoted 4 lines

AFAIK the only target that is so far supposed to work with --disable-tcg is i386. The configure script however lets you try to build without TCG if the host has an alternative accelerator (e.g. KVM), but that build is likely to fail. [ just confirmed this with aarch64 ]

What about s390x?

s390x and ppc64 supposedly support --disable-tcg?

Paolo

#6 lore raw
Quoted 8 lines · Paolo Bonzini
Quoted 5 lines · Philippe Mathieu-Daudé
Quoted 4 lines

AFAIK the only target that is so far supposed to work with --disable-tcg is i386. The configure script however lets you try to build without TCG if the host has an alternative accelerator (e.g. KVM), but that build is likely to fail. [ just confirmed this with aarch64 ]

What about s390x?

s390x and ppc64 supposedly support --disable-tcg?

s390x supports --disable-tcg, but ppc64 does not support it yet.

Thomas

#7 lore raw
In reply to Richard Henderson
Quoted 4 lines · Richard Henderson

Fix the build for --disable-tcg.

Fixes 55c3ceef61fcf06fc98ddc752b7cce788ce7680b
Quoted 8 lines
---
 target/arm/cpu.c            | 2 ++
 target/i386/cpu.c           | 2 ++
 target/mips/cpu.c           | 2 ++
 target/ppc/translate_init.c | 2 ++
 target/s390x/cpu.c          | 2 ++
 5 files changed, 10 insertions(+)

Applied to master as a buildfix, thanks.

-- PMM

#8 lore raw

Hi Peter,

Quoted 9 lines · Peter Maydell
Quoted 5 lines · Richard Henderson

Fix the build for --disable-tcg.

Fixes 55c3ceef61fcf06fc98ddc752b7cce788ce7680b

---

Applied to master as a buildfix, thanks.

I couldn't see this buildfix merged in /master so I provided another version using stubs and details about offending commits there:

http://lists.nongnu.org/archive/html/qemu-devel/2017-10/msg06530.html

In case you didn't pushed to /master you might consider this series instead.

I didn't include ARM/MIPS/PPC since they don't support building without TCG (yet).

Regards,

Phil.

#9 lore raw
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines

Fix the build for --disable-tcg.

Fixes 55c3ceef61fcf06fc98ddc752b7cce788ce7680b

---

Quoted 8 lines
Quoted 1 line

Applied to master as a buildfix, thanks.

I couldn't see this buildfix merged in /master so I provided another version using stubs and details about offending commits there:

http://lists.nongnu.org/archive/html/qemu-devel/2017-10/msg06530.html

In case you didn't pushed to /master you might consider this series instead.

Oops sorry I missed it in commit 74d7fc7f6385 and the conflicting merge 6e6430a821a1.