oneTBB
                                
                                
                                
                                    oneTBB copied to clipboard
                            
                            
                            
                        add generic arch as fallback to avoid "undefined __TBB_machine_fetchadd4"
https://buildd.debian.org/status/fetch.php?pkg=onetbb&arch=s390x&ver=2021.5.0-4&stamp=1644791435&raw=0
FAILED: src/tbb/CMakeFiles/tbb.dir/itt_notify.cpp.o 
/usr/bin/c++ -D__TBB_BUILD -D__TBB_USE_ITT_NOTIFY -I/<<PKGBUILDDIR>>/src/tbb/../../include -g -O2 -ffile-prefix-map=/<<PKGBUILDDIR>>=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -flifetime-dse=1 -Wall -Wextra -Werror -Wfatal-errors -flto -pthread -std=c++11 -MD -MT src/tbb/CMakeFiles/tbb.dir/itt_notify.cpp.o -MF src/tbb/CMakeFiles/tbb.dir/itt_notify.cpp.o.d -o src/tbb/CMakeFiles/tbb.dir/itt_notify.cpp.o -c /<<PKGBUILDDIR>>/src/tbb/itt_notify.cpp
In file included from /<<PKGBUILDDIR>>/src/tbb/tools_api/ittnotify_static.c:17,
                 from /<<PKGBUILDDIR>>/src/tbb/itt_notify.cpp:43:
/<<PKGBUILDDIR>>/src/tbb/tools_api/ittnotify_config.h: In function ‘long int __itt_interlocked_increment(volatile long int*)’:
/<<PKGBUILDDIR>>/src/tbb/tools_api/ittnotify_config.h:348:12: error: ‘__TBB_machine_fetchadd4’ was not declared in this scope
  348 |     return __TBB_machine_fetchadd4(ptr, 1) + 1L;
      |            ^~~~~~~~~~~~~~~~~~~~~~~
compilation terminated due to -Wfatal-errors.
This is because the s390x architecture  is not detected by the block of ITT_ARCH* macros. In the header file there is already a fallback implementation of __TBB_machine_fetchadd4. So the following patch is straightforward enough to avoid that issue.
Index: tbb/src/tbb/tools_api/ittnotify_config.h
===================================================================
--- tbb.orig/src/tbb/tools_api/ittnotify_config.h
+++ tbb/src/tbb/tools_api/ittnotify_config.h
@@ -159,6 +159,10 @@
 #  define ITT_ARCH_ARM64  6
 #endif /* ITT_ARCH_ARM64 */
 
+#ifndef ITT_ARCH_GENERIC
+#  define ITT_ARCH_GENERIC 99
+#endif /* ITT_ARCH_GENERIC */
+
 #ifndef ITT_ARCH
 #  if defined _M_IX86 || defined __i386__
 #    define ITT_ARCH ITT_ARCH_IA32
@@ -172,6 +176,8 @@
 #    define ITT_ARCH ITT_ARCH_ARM64
 #  elif defined __powerpc64__
 #    define ITT_ARCH ITT_ARCH_PPC64
+#  else
+#    define ITT_ARCH ITT_ARCH_GENERIC
 #  endif
 #endif
If this looks good to you, I can submit a PR. I guess that number has to be revised.
@ekovanova, can you please look at the patch?
BTW, I have added this patch to the 2021.05-5 version of debian package. It fixes the build failure for at least s390x, hppa (pa-risc), etc.
https://buildd.debian.org/status/package.php?p=onetbb&suite=experimental
@cdluminate I would like to have explicitly described s390x target architecture at my opinion it should be something like:
+#ifndef ITT_ARCH_S390X
+#  define ITT_ARCH_S390X 7
+#endif /* ITT_ARCH_S390X */
+#  elif defined __s390__ || defined __s390x__
+#    define ITT_ARCH ITT_ARCH_S390X
                                    
                                    
                                    
                                
@ekovanova Thanks. Then I'm going to submit a patch with more macros than merely s390x.
@cdluminate feel free to submit the PR to this repository :)
@ekovanova @alexey-katranov ping please..