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

building ps4 toolchain on mac M1 (arm64) #1

Open
bucanero opened this issue Sep 21, 2021 · 6 comments
Open

building ps4 toolchain on mac M1 (arm64) #1

bucanero opened this issue Sep 21, 2021 · 6 comments

Comments

@bucanero
Copy link

bucanero commented Sep 21, 2021

So I tried to build the toolchain on my macbook M1, but I'm finding some issues when building gdb
First configure couldn't find GMP (configure: error: GMP is missing or unusable), but I had it installed with Homebrew.

I did manage to force configure to detect libgmp using
./configure LDFLAGS=-L/opt/homebrew/lib

but, then I'm getting this error when trying to link gdb:

  CXXLD  gdb
Undefined symbols for architecture arm64:
  "darwin_set_sstep(unsigned int, int)", referenced from:
      darwin_resume_thread(inferior*, darwin_thread_info*, int, int) in darwin-nat.o
  "darwin_check_osabi(darwin_inferior*, unsigned int)", referenced from:
      darwin_nat_target::attach(char const*, int) in darwin-nat.o
  "_aarch64_mach_o_vec", referenced from:
      initialize_current_architecture() in arch-utils.o
  "_bfd_aarch64_arch", referenced from:
      initialize_current_architecture() in arch-utils.o
      gdbarch_info_fill(gdbarch_info*) in arch-utils.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [gdb] Error 1
make[1]: *** [all-gdb] Error 2
make: *** [all] Error 2

I built the PS3 toolchain PSL1GHT recently and had to do some patches to compile gcc 7.2 on arm64, due to missing symbols on too.

@psxdev
Copy link
Contributor

psxdev commented Sep 21, 2021

Are you sure that you are not mixing architecture libraries? Check that you are linking with arm libraries. I am using macport but with compiled packages in local for arm with no issues.

@bucanero
Copy link
Author

Are you sure that you are not mixing architecture libraries? Check that you are linking with arm libraries. I am using macport but with compiled packages in local for arm with no issues.

Yes, I'm pretty sure that the libraries are arm libraries. I was using those same libs to build the ps3-toolchain so I know they worked fine.
I guess I'll have to try with macports when I have a chance.

@bucanero
Copy link
Author

bucanero commented Oct 23, 2021

I had some free time to look again into this issue on my mac M1 (bigSur 11.6, using Brew as package manager), and I'm sharing this feedback in case it's helpful to other devs.

In the stage0-binutils.sh script, there's a reference to a 2.36.1 binutils branch, but for some reason I had some issues with git

BRANCH_NAME="binutils-2_36_1"

So, I ended up downloading the branch directly (just download & unzip): https://github.com/bminor/binutils-gdb/archive/refs/tags/binutils-2_36_1.zip

Then, I edited stage0-binutils.sh to add the library path for GMP, that I installed using brew:

- TARG_XTRA_OPTS=""
+ TARG_XTRA_OPTS="LDFLAGS=-L/opt/homebrew/lib"

after that, I was able to run stage0 and stage1 and build the PS4 toolchain properly on my M1 mac.
With the compiled toolchain, the rest of the scripts ran with no issues. (dotnet is required for pkgtool)

Edit: small note about PkgTool; I had to install the 6.0 SDK (macos arm64), then I updated the TargetFramework to 6.0 on the .csproj files:

- <TargetFramework>netcoreapp3.0</TargetFramework>
+ <TargetFramework>netcoreapp6.0</TargetFramework>

@fjtrujy
Copy link
Contributor

fjtrujy commented Oct 24, 2021

binutils-2_36_1

Hello @bucanero,
Just remove your build folder and try to run the script again, this specific binutils reference, for sure it exists.

About the flags you added to the binutils compilation, maybe are needed, we should put a specific if for that scenario.

Finally, about netcoreapp we require to use 3.1, because later on, there is a tool that is just working with this specific .net version.

Thanks

@bucanero
Copy link
Author

Hi @fjtrujy,
yes you're right, my apologies. The branch exists, but for some reason my git was giving some error about it. (link: https://github.com/bminor/binutils-gdb/tree/binutils-2_36_1 )

I assume that the added flags are only required if the user installs libgmp using Brew. But if there's no harm to add it, I can submit a PR with that change.

I had no idea about the specific netcore requirement. I'll try again then.

Also, I'd like to know how can I properly test this build and toolchain. I tried cloning orbisdev-sample, I was able to build and make a .pkg . I then installed the .pkg on my PS4 (6.72 running goldhen) , but when I tried to open the sample app the screen shows the "ORBISLINK" logo and stays there. Nothing else shows up, but I can press the PS button and go back to the main XMB.
So I'm not sure if I'm missing some additional setup to run the sample app (like having a config file or the NFS server) or if my toolchain is just broken and the binary is corrupt.

If you could provide some information on how to build and execute a simple "sample" app that would be great.
btw, if it's easier for you guys, I can join on discord or any other chat

Thanks again for the feedback!

@kosshylo
Copy link

@bucanero , @fjtrujy could you please provide more detailed how to fix problem on my mac with M1
"configure error gmp is missing" as for starter user of linux.

Goal: to make riscv-gnu-toolchain
Problem:
CXXLD gdb Undefined symbols for architecture arm64: "darwin_set_sstep(unsigned int, int)", referenced from: darwin_resume_thread(inferior*, darwin_thread_info*, int, int) in darwin-nat.o "darwin_check_osabi(darwin_inferior*, unsigned int)", referenced from: darwin_nat_target::attach(char const*, int) in darwin-nat.o "_aarch64_mach_o_vec", referenced from: initialize_current_architecture() in arch-utils.o "_bfd_aarch64_arch", referenced from: initialize_current_architecture() in arch-utils.o gdbarch_info_fill(gdbarch_info*) in arch-utils.o ld: symbol(s) not found for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation) make[2]: *** [gdb] Error 1 make[1]: *** [all-gdb] Error 2 make: *** [all] Error 2

  1. Where is I should find stage0-binutils.sh and stage1-binutils.sh ?
  2. Should I remove "binutils" folder from riscv-gnu-toolchain and set your zip https://github.com/bminor/binutils-gdb/archive/refs/tags/binutils-2_36_1.zip ?
  3. Could you please clarify location where I should find ".csproj" files ?

__
Best regards

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants