PS3 I updated the ps3toolchain to gcc 9.5.0/binutils 2.40

and another question, why not use a newlib version more recent? What are the incompatibilities?
The newlib patch is 400kB vs. 25kB of GCC, also a huge version jump from 1.20.0 to e.g. 4.3.0. Could be structured completely differently now, I don't know.

How I did the GCC update was to split the 7.2.0 patch into patches for each file and tried to apply them where possible, manually where not, with version control (git) to produce a new patch. Took me a couple days as I had to look up internal name changes of e.g. preprocessor constants etc. Looks like a lot of work if one wants to do this for newlib is what I'm trying to say.
 
Last edited:
The newlib patch is 400kB vs. 25kB of GCC, also a huge version jump from 1.20.0 to e.g. 4.3.0. Could be structured completely differently now, I don't know.

How I did the GCC update was to split the 7.2.0 patch into patches for each file and tried to apply them where possible, manually where not, with version control (git) to produce a new patch. Took me a couple days as I had to look up internal name changes of e.g. preprocessor constants etc. Looks like a lot of work if one wants to do this for newlib is what I'm trying to say.
I was able to update the newlib to version 2.5.0.20171222 from 2017, the 1.20.0 which is the ps3toolchain repository default is from 2011, the next version after 2.5.0.20171222 is 3.0.0, which deletes the libsysbase folder which is a folder we use and removes a bunch of other stuff, I couldn't find it in the changelog or google why it was removed, but anyway this is the last version compatible with the patch we have, gcc 9.5.0 was successfully compiled with this version of the newlib, however I had to create some extra patches, and I haven't tested it either, it's probably unstable, it's an experimental version anyway
 
Have anyone faced the following error?

Trying to compile std::thread
docker run -i --rm zeldin/ps3dev-docker bash -s <<EOF
echo '#include <iostream>
#include <thread>

// Function to be executed by the thread
void threadFunction(int threadID) {
std::cout << "Thread " << threadID << " is executing" << std::endl;
}

int main() {
// Creating a thread and passing a function to execute
std::thread t1(threadFunction, 1);

// Joining the thread to the main thread
t1.join();

// Output a message from the main thread
std::cout << "Main thread is executing" << std::endl;

return 0;
}' > oo.cpp
ppu-g++ oo.cpp -o oo -std=c++11
EOF
Output
oo.cpp: In function 'int main()':
oo.cpp:11:10: error: 'thread' is not a member of 'std'
std::thread t1(threadFunction, 1);
^~~~~~
oo.cpp:11:10: note: suggested alternative: 'tera'
std::thread t1(threadFunction, 1);
^~~~~~
tera
oo.cpp:14:5: error: 't1' was not declared in this scope
t1.join();
^~
oo.cpp:14:5: note: suggested alternative: 'tm'
t1.join();
^~
tm
 
Have anyone faced the following error?

Trying to compile std::thread
docker run -i --rm zeldin/ps3dev-docker bash -s <<EOF
echo '#include <iostream>
#include <thread>

// Function to be executed by the thread
void threadFunction(int threadID) {
std::cout << "Thread " << threadID << " is executing" << std::endl;
}

int main() {
// Creating a thread and passing a function to execute
std::thread t1(threadFunction, 1);

// Joining the thread to the main thread
t1.join();

// Output a message from the main thread
std::cout << "Main thread is executing" << std::endl;

return 0;
}' > oo.cpp
ppu-g++ oo.cpp -o oo -std=c++11
EOF
Output
oo.cpp: In function 'int main()':
oo.cpp:11:10: error: 'thread' is not a member of 'std'
std::thread t1(threadFunction, 1);
^~~~~~
oo.cpp:11:10: note: suggested alternative: 'tera'
std::thread t1(threadFunction, 1);
^~~~~~
tera
oo.cpp:14:5: error: 't1' was not declared in this scope
t1.join();
^~
oo.cpp:14:5: note: suggested alternative: 'tm'
t1.join();
^~
tm
You cannot use C++ threads on the PS3, there is no compatibility, you will have to call the PPU or SPU thread creation syscall
 
You cannot use C++ threads on the PS3, there is no compatibility, you will have to call the PPU or SPU thread creation syscall
Gee... Too bad. So, I'll have to rewrite the code.
Use ppu/spu directly would be painful.
So, I'm gonna use the pthread-emb-ps3 that already works on PS3.
It's written in C and only using export "C" on cpp source code and that would be the easiest way.

Code:
docker run -i --rm hldtux/ps3dev-sdl2 bash -s <<EOF
echo '#include <iostream>
extern "C" {
#include <pthread.h>
}

void* thread_function(void* arg) {
    std::cout << "Hello from thread\n";
    return nullptr;
}

int main() {
    pthread_t thread_id;
    pthread_create(&thread_id, nullptr, thread_function, nullptr);
    pthread_join(thread_id, nullptr);
    std::cout << "Back in main thread\n";
    return 0;
}' > main.cpp
ppu-g++ main.cpp -o main \
-I/usr/local/ps3dev/portlibs/ppu/include \
-L/usr/local/ps3dev/portlibs/ppu/lib -lpthread
EOF
 
There is no ppu-g++ in my ps3toolchain and there never will, so not sure what you're asking for here.

BTW, updated ppu-gcc to 13.2.0 and ppu-binutils to 2.42 in the meantime, contained in the ISO as well.
 
There is no ppu-g++ in my ps3toolchain and there never will, so not sure what you're asking for here.

BTW, updated ppu-gcc to 13.2.0 and ppu-binutils to 2.42 in the meantime, contained in the ISO as well.
Perfect, Thanks. Actually, I had used your patch and luizfernandonb's here https://github.com/ps3dev/ps3toolchain/pull/121
After upgrading ppu-g++ to version 13.2.0, I expected support for std::thread to be available. However, unfortunately, it didn't work as expected. I'm currently porting a C++11 application to PS3, which utilizes SDL2 and relies on std::thread. I've successfully addressed the SDL2 dependencies, but I'm encountering difficulties with std::thread support, which seems to be missing.
 
Back
Top