Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build failure because of non-static functions in SystemZ header #2643

Closed
thestr4ng3r opened this issue Mar 10, 2025 · 1 comment · Fixed by #2645
Closed

Build failure because of non-static functions in SystemZ header #2643

thestr4ng3r opened this issue Mar 10, 2025 · 1 comment · Fixed by #2645
Labels
build & packaging Build system and packaging related SystemZ Arch

Comments

@thestr4ng3r
Copy link
Contributor

Work environment

Questions Answers
System Capstone runs on OS/arch/bits OpenBSD 7.6 sparc64 (has a patched gcc 4.2.1)
Capstone module affected system z
Source of Capstone next branch
Version/git commit bb2f657

Expected behavior

capstone links

Actual behavior

sparc$ ninja -Cbuild -j1
ninja: Entering directory `build'
[3/7] Building C object CMakeFiles/capstone.dir/arch/SystemZ/SystemZMapping.c.o
In file included from /home/florian/dev/capstone/arch/SystemZ/SystemZMapping.c:9:
/home/florian/dev/capstone/arch/SystemZ/../../Mapping.h:72: warning: type qualifiers ignored on function return type
/home/florian/dev/capstone/arch/SystemZ/../../Mapping.h:77: warning: type qualifiers ignored on function return type
[6/7] Linking C executable fuzz_disasm
FAILED: fuzz_disasm
: && /usr/bin/cc -g  CMakeFiles/capstone.dir/cs.c.o CMakeFiles/capstone.dir/Mapping.c.o CMakeFiles/capstone.dir/MCInst.c.o CMakeFiles/capstone.dir/MCInstrDesc.c.o CMakeFiles/capstone.dir/MCInstPrinter.c.o CMakeFiles/capstone.dir/MCRegisterInfo.c.o CMakeFiles/capstone.dir/SStream.c.o CMakeFiles/capstone.dir/utils.c.o CMakeFiles/capstone.dir/arch/ARM/ARMBaseInfo.c.o CMakeFiles/capstone.dir/arch/ARM/ARMDisassembler.c.o CMakeFiles/capstone.dir/arch/ARM/ARMDisassemblerExtension.c.o CMakeFiles/capstone.dir/arch/ARM/ARMInstPrinter.c.o CMakeFiles/capstone.dir/arch/ARM/ARMMapping.c.o CMakeFiles/capstone.dir/arch/ARM/ARMModule.c.o CMakeFiles/capstone.dir/arch/AArch64/AArch64BaseInfo.c.o CMakeFiles/capstone.dir/arch/AArch64/AArch64Disassembler.c.o CMakeFiles/capstone.dir/arch/AArch64/AArch64DisassemblerExtension.c.o CMakeFiles/capstone.dir/arch/AArch64/AArch64InstPrinter.c.o CMakeFiles/capstone.dir/arch/AArch64/AArch64Mapping.c.o CMakeFiles/capstone.dir/arch/AArch64/AArch64Module.c.o CMakeFiles/capstone.dir/arch/Mips/MipsDisassembler.c.o CMakeFiles/capstone.dir/arch/Mips/MipsInstPrinter.c.o CMakeFiles/capstone.dir/arch/Mips/MipsMapping.c.o CMakeFiles/capstone.dir/arch/Mips/MipsModule.c.o CMakeFiles/capstone.dir/arch/PowerPC/PPCDisassembler.c.o CMakeFiles/capstone.dir/arch/PowerPC/PPCInstPrinter.c.o CMakeFiles/capstone.dir/arch/PowerPC/PPCMapping.c.o CMakeFiles/capstone.dir/arch/PowerPC/PPCModule.c.o CMakeFiles/capstone.dir/arch/X86/X86Disassembler.c.o CMakeFiles/capstone.dir/arch/X86/X86DisassemblerDecoder.c.o CMakeFiles/capstone.dir/arch/X86/X86IntelInstPrinter.c.o CMakeFiles/capstone.dir/arch/X86/X86InstPrinterCommon.c.o CMakeFiles/capstone.dir/arch/X86/X86Mapping.c.o CMakeFiles/capstone.dir/arch/X86/X86Module.c.o CMakeFiles/capstone.dir/arch/X86/X86ATTInstPrinter.c.o CMakeFiles/capstone.dir/arch/Sparc/SparcDisassembler.c.o CMakeFiles/capstone.dir/arch/Sparc/SparcInstPrinter.c.o CMakeFiles/capstone.dir/arch/Sparc/SparcMapping.c.o CMakeFiles/capstone.dir/arch/Sparc/SparcModule.c.o CMakeFiles/capstone.dir/arch/SystemZ/SystemZDisassembler.c.o CMakeFiles/capstone.dir/arch/SystemZ/SystemZDisassemblerExtension.c.o CMakeFiles/capstone.dir/arch/SystemZ/SystemZInstPrinter.c.o CMakeFiles/capstone.dir/arch/SystemZ/SystemZMapping.c.o CMakeFiles/capstone.dir/arch/SystemZ/SystemZModule.c.o CMakeFiles/capstone.dir/arch/SystemZ/SystemZMCTargetDesc.c.o CMakeFiles/capstone.dir/arch/XCore/XCoreDisassembler.c.o CMakeFiles/capstone.dir/arch/XCore/XCoreInstPrinter.c.o CMakeFiles/capstone.dir/arch/XCore/XCoreMapping.c.o CMakeFiles/capstone.dir/arch/XCore/XCoreModule.c.o CMakeFiles/capstone.dir/arch/M68K/M68KDisassembler.c.o CMakeFiles/capstone.dir/arch/M68K/M68KInstPrinter.c.o CMakeFiles/capstone.dir/arch/M68K/M68KModule.c.o CMakeFiles/capstone.dir/arch/TMS320C64x/TMS320C64xDisassembler.c.o CMakeFiles/capstone.dir/arch/TMS320C64x/TMS320C64xInstPrinter.c.o CMakeFiles/capstone.dir/arch/TMS320C64x/TMS320C64xMapping.c.o CMakeFiles/capstone.dir/arch/TMS320C64x/TMS320C64xModule.c.o CMakeFiles/capstone.dir/arch/M680X/M680XDisassembler.c.o CMakeFiles/capstone.dir/arch/M680X/M680XInstPrinter.c.o CMakeFiles/capstone.dir/arch/M680X/M680XModule.c.o CMakeFiles/capstone.dir/arch/EVM/EVMDisassembler.c.o CMakeFiles/capstone.dir/arch/EVM/EVMInstPrinter.c.o CMakeFiles/capstone.dir/arch/EVM/EVMMapping.c.o CMakeFiles/capstone.dir/arch/EVM/EVMModule.c.o CMakeFiles/capstone.dir/arch/WASM/WASMDisassembler.c.o CMakeFiles/capstone.dir/arch/WASM/WASMInstPrinter.c.o CMakeFiles/capstone.dir/arch/WASM/WASMMapping.c.o CMakeFiles/capstone.dir/arch/WASM/WASMModule.c.o CMakeFiles/capstone.dir/arch/MOS65XX/MOS65XXModule.c.o CMakeFiles/capstone.dir/arch/MOS65XX/MOS65XXDisassembler.c.o CMakeFiles/capstone.dir/arch/BPF/BPFDisassembler.c.o CMakeFiles/capstone.dir/arch/BPF/BPFInstPrinter.c.o CMakeFiles/capstone.dir/arch/BPF/BPFMapping.c.o CMakeFiles/capstone.dir/arch/BPF/BPFModule.c.o CMakeFiles/capstone.dir/arch/RISCV/RISCVDisassembler.c.o CMakeFiles/capstone.dir/arch/RISCV/RISCVInstPrinter.c.o CMakeFiles/capstone.dir/arch/RISCV/RISCVMapping.c.o CMakeFiles/capstone.dir/arch/RISCV/RISCVModule.c.o CMakeFiles/capstone.dir/arch/SH/SHDisassembler.c.o CMakeFiles/capstone.dir/arch/SH/SHInstPrinter.c.o CMakeFiles/capstone.dir/arch/SH/SHModule.c.o CMakeFiles/capstone.dir/arch/TriCore/TriCoreDisassembler.c.o CMakeFiles/capstone.dir/arch/TriCore/TriCoreInstPrinter.c.o CMakeFiles/capstone.dir/arch/TriCore/TriCoreMapping.c.o CMakeFiles/capstone.dir/arch/TriCore/TriCoreModule.c.o CMakeFiles/capstone.dir/arch/Alpha/AlphaDisassembler.c.o CMakeFiles/capstone.dir/arch/Alpha/AlphaInstPrinter.c.o CMakeFiles/capstone.dir/arch/Alpha/AlphaMapping.c.o CMakeFiles/capstone.dir/arch/Alpha/AlphaModule.c.o CMakeFiles/capstone.dir/arch/HPPA/HPPADisassembler.c.o CMakeFiles/capstone.dir/arch/HPPA/HPPAInstPrinter.c.o CMakeFiles/capstone.dir/arch/HPPA/HPPAMapping.c.o CMakeFiles/capstone.dir/arch/HPPA/HPPAModule.c.o CMakeFiles/capstone.dir/arch/LoongArch/LoongArchDisassembler.c.o CMakeFiles/capstone.dir/arch/LoongArch/LoongArchDisassemblerExtension.c.o CMakeFiles/capstone.dir/arch/LoongArch/LoongArchInstPrinter.c.o CMakeFiles/capstone.dir/arch/LoongArch/LoongArchMapping.c.o CMakeFiles/capstone.dir/arch/LoongArch/LoongArchModule.c.o CMakeFiles/capstone.dir/arch/Xtensa/XtensaDisassembler.c.o CMakeFiles/capstone.dir/arch/Xtensa/XtensaInstPrinter.c.o CMakeFiles/capstone.dir/arch/Xtensa/XtensaMapping.c.o CMakeFiles/capstone.dir/arch/Xtensa/XtensaModule.c.o CMakeFiles/capstone.dir/arch/ARC/ARCDisassembler.c.o CMakeFiles/capstone.dir/arch/ARC/ARCInstPrinter.c.o CMakeFiles/capstone.dir/arch/ARC/ARCMapping.c.o CMakeFiles/capstone.dir/arch/ARC/ARCModule.c.o CMakeFiles/fuzz_disasm.dir/suite/fuzz/onefile.c.o CMakeFiles/fuzz_disasm.dir/suite/fuzz/fuzz_disasm.c.o CMakeFiles/fuzz_disasm.dir/suite/fuzz/platform.c.o -o fuzz_disasm  -Wl,-rpath-link,/usr/X11R6/lib:/usr/local/lib && :
CMakeFiles/capstone.dir/arch/SystemZ/SystemZDisassemblerExtension.c.o: In function `SystemZMC_getRegAsGR64':
/home/florian/dev/capstone/arch/SystemZ/SystemZMCTargetDesc.h:74: multiple definition of `SystemZMC_getRegAsGR64'
CMakeFiles/capstone.dir/arch/SystemZ/SystemZDisassembler.c.o:/home/florian/dev/capstone/arch/SystemZ/SystemZMCTargetDesc.h:74: first defined here
CMakeFiles/capstone.dir/arch/SystemZ/SystemZDisassemblerExtension.c.o: In function `SystemZMC_getRegAsGR32':
/home/florian/dev/capstone/arch/SystemZ/SystemZMCTargetDesc.h:80: multiple definition of `SystemZMC_getRegAsGR32'
CMakeFiles/capstone.dir/arch/SystemZ/SystemZDisassembler.c.o:/home/florian/dev/capstone/arch/SystemZ/SystemZMCTargetDesc.h:80: first defined here
CMakeFiles/capstone.dir/arch/SystemZ/SystemZDisassemblerExtension.c.o: In function `SystemZMC_getRegAsGRH32':
/home/florian/dev/capstone/arch/SystemZ/SystemZMCTargetDesc.h:86: multiple definition of `SystemZMC_getRegAsGRH32'
CMakeFiles/capstone.dir/arch/SystemZ/SystemZDisassembler.c.o:/home/florian/dev/capstone/arch/SystemZ/SystemZMCTargetDesc.h:86: first defined here
CMakeFiles/capstone.dir/arch/SystemZ/SystemZDisassemblerExtension.c.o: In function `SystemZMC_getRegAsVR128':
/home/florian/dev/capstone/arch/SystemZ/SystemZMCTargetDesc.h:92: multiple definition of `SystemZMC_getRegAsVR128'
CMakeFiles/capstone.dir/arch/SystemZ/SystemZDisassembler.c.o:/home/florian/dev/capstone/arch/SystemZ/SystemZMCTargetDesc.h:92: first defined here
CMakeFiles/capstone.dir/arch/SystemZ/SystemZMapping.c.o: In function `SystemZMC_getRegAsGR64':
/home/florian/dev/capstone/arch/SystemZ/SystemZMCTargetDesc.h:74: multiple definition of `SystemZMC_getRegAsGR64'
CMakeFiles/capstone.dir/arch/SystemZ/SystemZDisassembler.c.o:/home/florian/dev/capstone/arch/SystemZ/SystemZMCTargetDesc.h:74: first defined here
CMakeFiles/capstone.dir/arch/SystemZ/SystemZMapping.c.o: In function `SystemZMC_getRegAsGR32':
/home/florian/dev/capstone/arch/SystemZ/SystemZMCTargetDesc.h:80: multiple definition of `SystemZMC_getRegAsGR32'
CMakeFiles/capstone.dir/arch/SystemZ/SystemZDisassembler.c.o:/home/florian/dev/capstone/arch/SystemZ/SystemZMCTargetDesc.h:80: first defined here
CMakeFiles/capstone.dir/arch/SystemZ/SystemZMapping.c.o: In function `SystemZMC_getRegAsGRH32':
/home/florian/dev/capstone/arch/SystemZ/SystemZMCTargetDesc.h:86: multiple definition of `SystemZMC_getRegAsGRH32'
CMakeFiles/capstone.dir/arch/SystemZ/SystemZDisassembler.c.o:/home/florian/dev/capstone/arch/SystemZ/SystemZMCTargetDesc.h:86: first defined here
CMakeFiles/capstone.dir/arch/SystemZ/SystemZMapping.c.o: In function `SystemZMC_getRegAsVR128':
/home/florian/dev/capstone/arch/SystemZ/SystemZMCTargetDesc.h:92: multiple definition of `SystemZMC_getRegAsVR128'
CMakeFiles/capstone.dir/arch/SystemZ/SystemZDisassembler.c.o:/home/florian/dev/capstone/arch/SystemZ/SystemZMCTargetDesc.h:92: first defined here
CMakeFiles/capstone.dir/arch/SystemZ/SystemZMCTargetDesc.c.o: In function `SystemZMC_getRegAsGR64':
/home/florian/dev/capstone/arch/SystemZ/SystemZMCTargetDesc.h:74: multiple definition of `SystemZMC_getRegAsGR64'
CMakeFiles/capstone.dir/arch/SystemZ/SystemZDisassembler.c.o:/home/florian/dev/capstone/arch/SystemZ/SystemZMCTargetDesc.h:74: first defined here
CMakeFiles/capstone.dir/arch/SystemZ/SystemZMCTargetDesc.c.o: In function `SystemZMC_getRegAsGR32':
/home/florian/dev/capstone/arch/SystemZ/SystemZMCTargetDesc.h:80: multiple definition of `SystemZMC_getRegAsGR32'
CMakeFiles/capstone.dir/arch/SystemZ/SystemZDisassembler.c.o:/home/florian/dev/capstone/arch/SystemZ/SystemZMCTargetDesc.h:80: first defined here
CMakeFiles/capstone.dir/arch/SystemZ/SystemZMCTargetDesc.c.o: In function `SystemZMC_getRegAsGRH32':
/home/florian/dev/capstone/arch/SystemZ/SystemZMCTargetDesc.h:86: multiple definition of `SystemZMC_getRegAsGRH32'
CMakeFiles/capstone.dir/arch/SystemZ/SystemZDisassembler.c.o:/home/florian/dev/capstone/arch/SystemZ/SystemZMCTargetDesc.h:86: first defined here
CMakeFiles/capstone.dir/arch/SystemZ/SystemZMCTargetDesc.c.o: In function `SystemZMC_getRegAsVR128':
/home/florian/dev/capstone/arch/SystemZ/SystemZMCTargetDesc.h:92: multiple definition of `SystemZMC_getRegAsVR128'
CMakeFiles/capstone.dir/arch/SystemZ/SystemZDisassembler.c.o:/home/florian/dev/capstone/arch/SystemZ/SystemZMCTargetDesc.h:92: first defined here
collect2: ld returned 1 exit status
ninja: build stopped: subcommand failed.

Steps to reproduce the behavior

build on the above platform

Additional Logs, screenshots, source code, configuration dump, ...

Functions defined in headers should always be static to avoid conflicts between multiple compilation units. The following is a fix, but this should perhaps be made part of the C++ translation @Rot127

diff --git a/arch/SystemZ/SystemZMCTargetDesc.h b/arch/SystemZ/SystemZMCTargetDesc.h
index 0441a658..ab199d7f 100644
--- a/arch/SystemZ/SystemZMCTargetDesc.h
+++ b/arch/SystemZ/SystemZMCTargetDesc.h
@@ -70,25 +70,25 @@ extern const unsigned SystemZMC_CR64Regs[16];
 unsigned SystemZMC_getFirstReg(unsigned Reg);

 // Return the given register as a GR64.
-inline unsigned SystemZMC_getRegAsGR64(unsigned Reg)
+static inline unsigned SystemZMC_getRegAsGR64(unsigned Reg)
 {
        return SystemZMC_GR64Regs[SystemZMC_getFirstReg(Reg)];
 }

 // Return the given register as a low GR32.
-inline unsigned SystemZMC_getRegAsGR32(unsigned Reg)
+static inline unsigned SystemZMC_getRegAsGR32(unsigned Reg)
 {
        return SystemZMC_GR32Regs[SystemZMC_getFirstReg(Reg)];
 }

 // Return the given register as a high GR32.
-inline unsigned SystemZMC_getRegAsGRH32(unsigned Reg)
+static inline unsigned SystemZMC_getRegAsGRH32(unsigned Reg)
 {
        return SystemZMC_GRH32Regs[SystemZMC_getFirstReg(Reg)];
 }

 // Return the given register as a VR128.
-inline unsigned SystemZMC_getRegAsVR128(unsigned Reg)
+static inline unsigned SystemZMC_getRegAsVR128(unsigned Reg)
 {
        return SystemZMC_VR128Regs[SystemZMC_getFirstReg(Reg)];
 }
@Rot127 Rot127 added SystemZ Arch build & packaging Build system and packaging related labels Mar 10, 2025
@Rot127
Copy link
Collaborator

Rot127 commented Mar 10, 2025

but this should perhaps be made part of the C++ translation

If we fix it manually and save the changes, they should be automatically applied with the next update. Will take care of it with the C99 build issues.

This was referenced Mar 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build & packaging Build system and packaging related SystemZ Arch
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants