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

ProcessorTargets: support PowerPC #7051

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

barracuda156
Copy link

-march is unsupported on PowerPC, -mcpu is supported but may produce incorrect code on some targets; -mtune is supported and works robustly.

@barracuda156
Copy link
Author

There is one more related issue, -mtune=generic flag is wrong and breaks configure:

    kind: "try_compile-v1"
    backtrace:
      - "/opt/local/share/cmake-3.29/Modules/Internal/CheckSourceCompiles.cmake:101 (try_compile)"
      - "/opt/local/share/cmake-3.29/Modules/CheckCXXSourceCompiles.cmake:52 (cmake_check_source_compiles)"
      - "cmake/modules/FindATOMIC.cmake:19 (check_cxx_source_compiles)"
      - "CMakeLists.txt:581 (find_package)"
    checks:
      - "Performing Test HAVE_CXX_ATOMICS_WITHOUT_LIB"
    directories:
      source: "/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_graphics_rawtherapee/rawtherapee/work/build/CMakeFiles/CMakeScratch/TryCompile-lR29Bx"
      binary: "/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_graphics_rawtherapee/rawtherapee/work/build/CMakeFiles/CMakeScratch/TryCompile-lR29Bx"
    cmakeVariables:
      CMAKE_CXX_FLAGS: "-pipe -DNDEBUG -I/opt/local/include -D_GLIBCXX_USE_CXX11_ABI=0 -std=c++11 -ffp-contract=off -mtune=native -Werror=unused-label -Werror=delete-incomplete -fno-math-errno -Wno-attributes -mmacosx-version-min=10.6"
      CMAKE_CXX_FLAGS_DEBUG: "-g"
      CMAKE_EXE_LINKER_FLAGS: "-L/opt/local/lib -Wl,-headerpad_max_install_names -mtune=native -Wl,-headerpad_max_install_names -mtune=generic -framework Foundation"
      CMAKE_MODULE_PATH: "/opt/local/share/cmake/Modules;/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_graphics_rawtherapee/rawtherapee/work/rawtherapee-5.10/cmake/modules/"
      CMAKE_OSX_ARCHITECTURES: "ppc"
      CMAKE_OSX_DEPLOYMENT_TARGET: "10.6"
      CMAKE_OSX_SYSROOT: "/"
      CMAKE_WARN_DEPRECATED: "FALSE"
    buildResult:
      variable: "HAVE_CXX_ATOMICS_WITHOUT_LIB"
      cached: true
      stdout: |
        Change Dir: '/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_graphics_rawtherapee/rawtherapee/work/build/CMakeFiles/CMakeScratch/TryCompile-lR29Bx'
        
        Run Build Command(s): /opt/local/bin/cmake -E env VERBOSE=1 /usr/bin/make -f Makefile cmTC_76e75/fast
        /usr/bin/make  -f CMakeFiles/cmTC_76e75.dir/build.make CMakeFiles/cmTC_76e75.dir/build
        Building CXX object CMakeFiles/cmTC_76e75.dir/src.cxx.o
        /opt/local/bin/g++-mp-13 -DHAVE_CXX_ATOMICS_WITHOUT_LIB  -pipe -DNDEBUG -I/opt/local/include -D_GLIBCXX_USE_CXX11_ABI=0 -std=c++11 -ffp-contract=off -mtune=native -Werror=unused-label -Werror=delete-incomplete -fno-math-errno -Wno-attributes -mmacosx-version-min=10.6  -arch ppc -mmacosx-version-min=10.6 -o CMakeFiles/cmTC_76e75.dir/src.cxx.o -c /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_graphics_rawtherapee/rawtherapee/work/build/CMakeFiles/CMakeScratch/TryCompile-lR29Bx/src.cxx
        Linking CXX executable cmTC_76e75
        /opt/local/bin/cmake -E cmake_link_script CMakeFiles/cmTC_76e75.dir/link.txt --verbose=1
        /opt/local/bin/g++-mp-13 -pipe -DNDEBUG -I/opt/local/include -D_GLIBCXX_USE_CXX11_ABI=0 -std=c++11 -ffp-contract=off -mtune=native -Werror=unused-label -Werror=delete-incomplete -fno-math-errno -Wno-attributes -mmacosx-version-min=10.6  -arch ppc -mmacosx-version-min=10.6 -Wl,-search_paths_first -Wl,-headerpad_max_install_names -L/opt/local/lib -Wl,-headerpad_max_install_names -mtune=native -Wl,-headerpad_max_install_names -mtune=generic -framework Foundation  CMakeFiles/cmTC_76e75.dir/src.cxx.o -o cmTC_76e75
        g++-mp-13: error: unrecognized argument in option '-mtune=generic'
        g++-mp-13: note: valid arguments to '-mtune=' are: 401 403 405 405fp 440 440fp 464 464fp 476 476fp 505 601 602 603 603e 604 604e 620 630 740 7400 7450 750 801 821 823 8540 8548 860 970 G3 G4 G5 a2 cell e300c2 e300c3 e500mc e500mc64 e5500 e6500 ec603e native power10 power3 power4 power5 power5+ power6 power6x power7 power8 power9 powerpc powerpc64 powerpc64le rs64 titan
        make[1]: *** [cmTC_76e75] Error 1
        make: *** [cmTC_76e75/fast] Error 2
        
      exitCode: 2
  -
    kind: "try_compile-v1"
    backtrace:
      - "/opt/local/share/cmake-3.29/Modules/Internal/CheckSourceCompiles.cmake:101 (try_compile)"
      - "/opt/local/share/cmake-3.29/Modules/CheckCXXSourceCompiles.cmake:52 (cmake_check_source_compiles)"
      - "cmake/modules/FindATOMIC.cmake:23 (check_cxx_source_compiles)"
      - "CMakeLists.txt:581 (find_package)"
    checks:
      - "Performing Test HAVE_CXX_ATOMICS_WITH_LIB"
    directories:
      source: "/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_graphics_rawtherapee/rawtherapee/work/build/CMakeFiles/CMakeScratch/TryCompile-yX1egn"
      binary: "/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_graphics_rawtherapee/rawtherapee/work/build/CMakeFiles/CMakeScratch/TryCompile-yX1egn"
    cmakeVariables:
      CMAKE_CXX_FLAGS: "-pipe -DNDEBUG -I/opt/local/include -D_GLIBCXX_USE_CXX11_ABI=0 -std=c++11 -ffp-contract=off -mtune=native -Werror=unused-label -Werror=delete-incomplete -fno-math-errno -Wno-attributes -mmacosx-version-min=10.6"
      CMAKE_CXX_FLAGS_DEBUG: "-g"
      CMAKE_EXE_LINKER_FLAGS: "-L/opt/local/lib -Wl,-headerpad_max_install_names -mtune=native -Wl,-headerpad_max_install_names -mtune=generic -framework Foundation"
      CMAKE_MODULE_PATH: "/opt/local/share/cmake/Modules;/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_graphics_rawtherapee/rawtherapee/work/rawtherapee-5.10/cmake/modules/"
      CMAKE_OSX_ARCHITECTURES: "ppc"
      CMAKE_OSX_DEPLOYMENT_TARGET: "10.6"
      CMAKE_OSX_SYSROOT: "/"
      CMAKE_WARN_DEPRECATED: "FALSE"
    buildResult:
      variable: "HAVE_CXX_ATOMICS_WITH_LIB"
      cached: true
      stdout: |
        Change Dir: '/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_graphics_rawtherapee/rawtherapee/work/build/CMakeFiles/CMakeScratch/TryCompile-yX1egn'
        
        Run Build Command(s): /opt/local/bin/cmake -E env VERBOSE=1 /usr/bin/make -f Makefile cmTC_ebe89/fast
        /usr/bin/make  -f CMakeFiles/cmTC_ebe89.dir/build.make CMakeFiles/cmTC_ebe89.dir/build
        Building CXX object CMakeFiles/cmTC_ebe89.dir/src.cxx.o
        /opt/local/bin/g++-mp-13 -DHAVE_CXX_ATOMICS_WITH_LIB  -pipe -DNDEBUG -I/opt/local/include -D_GLIBCXX_USE_CXX11_ABI=0 -std=c++11 -ffp-contract=off -mtune=native -Werror=unused-label -Werror=delete-incomplete -fno-math-errno -Wno-attributes -mmacosx-version-min=10.6  -arch ppc -mmacosx-version-min=10.6 -o CMakeFiles/cmTC_ebe89.dir/src.cxx.o -c /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_graphics_rawtherapee/rawtherapee/work/build/CMakeFiles/CMakeScratch/TryCompile-yX1egn/src.cxx
        Linking CXX executable cmTC_ebe89
        /opt/local/bin/cmake -E cmake_link_script CMakeFiles/cmTC_ebe89.dir/link.txt --verbose=1
        /opt/local/bin/g++-mp-13 -pipe -DNDEBUG -I/opt/local/include -D_GLIBCXX_USE_CXX11_ABI=0 -std=c++11 -ffp-contract=off -mtune=native -Werror=unused-label -Werror=delete-incomplete -fno-math-errno -Wno-attributes -mmacosx-version-min=10.6  -arch ppc -mmacosx-version-min=10.6 -Wl,-search_paths_first -Wl,-headerpad_max_install_names -L/opt/local/lib -Wl,-headerpad_max_install_names -mtune=native -Wl,-headerpad_max_install_names -mtune=generic -framework Foundation  CMakeFiles/cmTC_ebe89.dir/src.cxx.o -o cmTC_ebe89  -latomic
        g++-mp-13: error: unrecognized argument in option '-mtune=generic'
        g++-mp-13: note: valid arguments to '-mtune=' are: 401 403 405 405fp 440 440fp 464 464fp 476 476fp 505 601 602 603 603e 604 604e 620 630 740 7400 7450 750 801 821 823 8540 8548 860 970 G3 G4 G5 a2 cell e300c2 e300c3 e500mc e500mc64 e5500 e6500 ec603e native power10 power3 power4 power5 power5+ power6 power6x power7 power8 power9 powerpc powerpc64 powerpc64le rs64 titan
        make[1]: *** [cmTC_ebe89] Error 1
        make: *** [cmTC_ebe89/fast] Error 2
        
      exitCode: 2

In fact in should not be set in that place at all, but rather in processor targets.

@Floessie
Copy link
Collaborator

There's no need to define PROC_TARGET_NUMBER and leaving it out is actually the "trick" to build RT on foreign architectures.

I don't think this patch is needed, but it's up to @Lawrence37 to decide.

@barracuda156
Copy link
Author

@Floessie -mtune=native is a safe optimization (binaries will still run on other types), but it gives some benefits in terms of speed due to better instruction scheduling.

(-mtune=generic should not be unconditionally used though, that one is breaking.)

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

Successfully merging this pull request may close these issues.

None yet

2 participants