>+#ifdef ACCEL_COMPILER >+ /* Decls are placed in reversed order in fat-objects, so we need to >+ revert them back if we compile target. */ >...
Actually this change is incorrect. If host binary is built with -flto, then both host gcc and target gcc read decls from lto and target_lto sections in the same order, and resulting tables are identical. So, in this case there is no need to change the order. But what if one wants to link non-lto host object files with a target image, produced from target_lto sections? In this case the order of host table, produced during ordinary compilation will differ from the order of target table, produced during lto compilation. Jakub, what do you think? Here is a simple example with 4 functions and 4 global variables: #define N 100 #pragma omp declare target int arr1[N]; int arr2[N]; int arr3[N]; int arr4[N]; #pragma omp end declare target void foo () { #pragma omp target for (int i = 0; i < N; i++) arr1[i] = 41 + i; #pragma omp target for (int i = 0; i < N; i++) arr2[i] = 42 + i; #pragma omp target for (int i = 0; i < N; i++) arr3[i] = 43 + i; #pragma omp target for (int i = 0; i < N; i++) arr4[i] = 44 + i; } I print DECL_NAME ((*v_funcs)[i]) and DECL_NAME ((*v_vars)[i]) in omp_finish_file: Host compilation: $ gcc -std=c99 -fopenmp -flto -c test.c -o test.o host func 0: foo._omp_fn.0 host func 1: foo._omp_fn.1 host func 2: foo._omp_fn.2 host func 3: foo._omp_fn.3 host var 0: arr4 host var 1: arr3 host var 2: arr2 host var 3: arr1 Host lto and target lto: $ gcc -std=c99 -fopenmp -flto test.o -o test host func 0: foo._omp_fn.3 host func 1: foo._omp_fn.2 host func 2: foo._omp_fn.1 host func 3: foo._omp_fn.0 host var 0: arr4 host var 1: arr3 host var 2: arr2 host var 3: arr1 target func 0: foo._omp_fn.3 target func 1: foo._omp_fn.2 target func 2: foo._omp_fn.1 target func 3: foo._omp_fn.0 target var 0: arr4 target var 1: arr3 target var 2: arr2 target var 3: arr1 The func tables produced during ordinary compilation and lto are different. -- Ilya