radareorg / radare2

UNIX-like reverse engineering framework and command-line toolset
https://www.radare.org/
GNU Lesser General Public License v3.0
19.96k stars 2.96k forks source link

Wrong value of triple on PowerPC: `PowerMacintosh-unknown-darwin` instead of `powerpc-apple-darwin` #22956

Open barracuda156 opened 1 month ago

barracuda156 commented 1 month ago

Description

Build system misdetects the triple:

checking build system type... PowerMacintosh-unknown-darwin
checking host system type... PowerMacintosh-unknown-darwin
checking target system type... PowerMacintosh-unknown-darwin

The issue is likely that mk/gcc.mk uses uname -m on Darwin, but that does not return the processor family or an arch; on a powerpc Mac is returns a rather unusable Power Macintosh.

What returns the correct value in a case of a ppc build is uname -p. Notice, though, that this still cannot be used with -arch flag, since it is not the build arch, but cpu family. And for ppc64 build the correct triple will be powerpc64-apple-darwin*.

Also, for macOS it should be powerpc*-apple-darwin*; not sure what is the correct value for Pure Darwin (if anyone still uses it).

Environment

36-244% date
Tue May 21 16:47:29 CST 2024
36-244% uname -ms
Darwin Power Macintosh
trufae commented 1 month ago

This triplet is generated by acr. would you like to try to submit a pr there to fix the “unknown” id?

trufae commented 1 month ago

But this shouldnt affect de build

barracuda156 commented 1 month ago

@trufae The build is broken for unrelated reason: https://github.com/radareorg/radare2/issues/22955

I will check what’s going on with the triple here. Even if affecting nothing, it will be nice to have it fixed.

trufae commented 4 weeks ago

Can you do the fix in https://github.com/radareorg/acr/blob/ac9f0d400a6152d04fa30cffea2c79c29ab156cd/src/acr-sh#L1628 to generate the right triplet?