Fix symbol clash on bunlded static libs

This commit is contained in:
lazymio 2022-04-04 11:24:59 +02:00
parent e188591695
commit 2f113b11d1
No known key found for this signature in database
GPG Key ID: DFF27E34A47CB873
7 changed files with 32 additions and 50 deletions

View File

@ -68,7 +68,7 @@ fn build_with_cmake() {
let profile = env::var("PROFILE").unwrap();
if let Some(unicorn_dir) = find_unicorn(&out_dir()) {
let rust_build_path = unicorn_dir.join("rust_build");
let rust_build_path = unicorn_dir.join("build_rust");
println!(
"cargo:rustc-link-search={}",
rust_build_path.to_str().unwrap()
@ -89,7 +89,7 @@ fn build_with_cmake() {
download_unicorn()
};
let rust_build_path = unicorn_dir.join("rust_build");
let rust_build_path = unicorn_dir.join("build_rust");
let mut cmd = Command::new("cmake");
@ -98,7 +98,7 @@ fn build_with_cmake() {
// Windows
cmd.current_dir(&unicorn_dir)
.arg("-B")
.arg("rust_build")
.arg("build_rust")
.arg("-DBUILD_SHARED_LIBS=OFF")
.arg("-G")
.arg("Visual Studio 16 2019");
@ -138,7 +138,7 @@ fn build_with_cmake() {
let mut cmd = Command::new("cmake");
cmd.current_dir(&unicorn_dir)
.arg("-B")
.arg("rust_build")
.arg("build_rust")
.arg("-DBUILD_SHARED_LIBS=OFF");
if profile == "debug" {
@ -163,35 +163,8 @@ fn build_with_cmake() {
}
}
// This is a workaround for Unicorn static link since libunicorn.a is also linked again lib*-softmmu.a.
// Static libs is just a bundle of objects files. The link relation defined in CMakeLists is only
// valid within the cmake project scope and cmake would help link again sub static libs automatically.
//
// Lazymio(@wtdcode): Why do I stick to static link? See: https://github.com/rust-lang/cargo/issues/5077
println!("cargo:rustc-link-lib=unicorn");
for arch in [
"x86_64",
"arm",
"aarch64",
"riscv32",
"riscv64",
"mips",
"mipsel",
"mips64",
"mips64el",
"sparc",
"sparc64",
"m68k",
"ppc",
"ppc64",
"s390x"
]
.iter()
{
println!("cargo:rustc-link-lib={}-softmmu", arch);
}
println!("cargo:rustc-link-lib=unicorn-common");
println!("cargo:rustc-link-lib=unicorn-static");
println!("cargo:rerun-if-changed=build.rs");
println!("cargo:rerun-if-changed=src");
}

View File

@ -1439,6 +1439,25 @@ static void tcg_commit(MemoryListener *listener)
tlb_flush(cpuas->cpu);
}
static uint64_t unassigned_io_read(struct uc_struct *uc, void* opaque, hwaddr addr, unsigned size)
{
#ifdef _MSC_VER
return (uint64_t)0xffffffffffffffffULL;
#else
return (uint64_t)-1ULL;
#endif
}
static void unassigned_io_write(struct uc_struct *uc, void* opaque, hwaddr addr, uint64_t data, unsigned size)
{
}
static const MemoryRegionOps unassigned_io_ops = {
.read = unassigned_io_read,
.write = unassigned_io_write,
.endianness = DEVICE_NATIVE_ENDIAN,
};
static void memory_map_init(struct uc_struct *uc)
{
uc->system_memory = g_malloc(sizeof(*(uc->system_memory)));

View File

@ -40,8 +40,6 @@ typedef struct MemoryRegionPortio {
#define PORTIO_END_OF_LIST() { }
extern const MemoryRegionOps unassigned_io_ops;
void cpu_outb(struct uc_struct *uc, uint32_t addr, uint8_t val);
void cpu_outw(struct uc_struct *uc, uint32_t addr, uint16_t val);
void cpu_outl(struct uc_struct *uc, uint32_t addr, uint32_t val);

View File

@ -1278,4 +1278,7 @@
#define gen_helper_cpsr_read gen_helper_cpsr_read_s390x
#define gen_helper_cpsr_write gen_helper_cpsr_write_s390x
#define helper_uc_s390x_exit helper_uc_s390x_exit_s390x
#define tcg_s390_tod_updated tcg_s390_tod_updated_s390x
#define tcg_s390_program_interrupt tcg_s390_program_interrupt_s390x
#define tcg_s390_data_exception tcg_s390_data_exception_s390x
#endif

View File

@ -26,7 +26,7 @@
#include "exec/exec-all.h"
#include "exec/cpu_ldst.h"
#include "hw/s390x/ioinst.h"
#//include "exec/address-spaces.h"
//include "exec/address-spaces.h"
#include "tcg_s390x.h"
#include "sysemu/sysemu.h"
//#include "hw/s390x/s390_flic.h"

View File

@ -14,17 +14,3 @@
#include "qemu-common.h"
#include "cpu.h"
#include "tcg_s390x.h"
void tcg_s390_tod_updated(CPUState *cs, run_on_cpu_data opaque)
{
}
void QEMU_NORETURN tcg_s390_program_interrupt(CPUS390XState *env,
uint32_t code, uintptr_t ra)
{
g_assert_not_reached();
}
void QEMU_NORETURN tcg_s390_data_exception(CPUS390XState *env, uint32_t dxc,
uintptr_t ra)
{
g_assert_not_reached();
}

View File

@ -6269,6 +6269,9 @@ ppc_irq_reset \
ppc64_SYMBOLS=${ppc_SYMBOLS}
s390x_SYMBOLS="helper_uc_s390x_exit \
tcg_s390_tod_updated \
tcg_s390_program_interrupt \
tcg_s390_data_exception \
"
ARCHS="x86_64 arm aarch64 riscv32 riscv64 mips mipsel mips64 mips64el sparc sparc64 m68k ppc ppc64 s390x"