Message ID | 20240821142525.106958-1-hjl.tools@gmail.com |
---|---|
State | New |
Headers | show |
Series | [v3] Update LDPT_REGISTER_CLAIM_FILE_HOOK_V2 linker plugin hook | expand |
On Wed, Aug 21, 2024 at 4:25 PM H.J. Lu <hjl.tools@gmail.com> wrote: > > This hook allows the BFD linker plugin to distinguish calls to > claim_file_handler that know the object is being used by the linker > (from ldmain.c:add_archive_element), from calls that don't know it's > being used by the linker (from elf_link_is_defined_archive_symbol); in > the latter case, the plugin should avoid including the unused LTO archive > members in link output. To get the proper support for archives with LTO > common symbols, the linker fix OK. Thanks, Richard. > commit a6f8fe0a9e9cbe871652e46ba7c22d5e9fb86208 > Author: H.J. Lu <hjl.tools@gmail.com> > Date: Wed Aug 14 20:50:02 2024 -0700 > > lto: Don't include unused LTO archive members in output > > is required. > > PR lto/116361 > * lto-plugin.c (claim_file_handler_v2): Rename claimed to > can_be_claimed. Include the LTO object only if it is known to > be included in link output. > > Signed-off-by: H.J. Lu <hjl.tools@gmail.com> > --- > lto-plugin/lto-plugin.c | 53 ++++++++++++++++++++++++----------------- > 1 file changed, 31 insertions(+), 22 deletions(-) > > diff --git a/lto-plugin/lto-plugin.c b/lto-plugin/lto-plugin.c > index 152648338b9..61b0de62f52 100644 > --- a/lto-plugin/lto-plugin.c > +++ b/lto-plugin/lto-plugin.c > @@ -1191,16 +1191,19 @@ process_offload_section (void *data, const char *name, off_t offset, off_t len) > return 1; > } > > -/* Callback used by a linker to check if the plugin will claim FILE. Writes > - the result in CLAIMED. If KNOWN_USED, the object is known by the linker > - to be used, or an older API version is in use that does not provide that > - information; otherwise, the linker is only determining whether this is > - a plugin object and it should not be registered as having offload data if > - not claimed by the plugin. */ > +/* Callback used by a linker to check if the plugin can claim FILE. > + Writes the result in CAN_BE_CLAIMED. If KNOWN_USED != 0, the object > + is known by the linker to be included in link output, or an older API > + version is in use that does not provide that information. Otherwise, > + the linker is only determining whether this is a plugin object and > + only the symbol table is needed by the linker. In this case, the > + object should not be included in link output and this function will > + be called by the linker again with KNOWN_USED != 0 after the linker > + decides the object should be included in link output. */ > > static enum ld_plugin_status > -claim_file_handler_v2 (const struct ld_plugin_input_file *file, int *claimed, > - int known_used) > +claim_file_handler_v2 (const struct ld_plugin_input_file *file, > + int *can_be_claimed, int known_used) > { > enum ld_plugin_status status; > struct plugin_objfile obj; > @@ -1229,7 +1232,7 @@ claim_file_handler_v2 (const struct ld_plugin_input_file *file, int *claimed, > } > lto_file.handle = file->handle; > > - *claimed = 0; > + *can_be_claimed = 0; > obj.file = file; > obj.found = 0; > obj.offload = false; > @@ -1286,15 +1289,19 @@ claim_file_handler_v2 (const struct ld_plugin_input_file *file, int *claimed, > lto_file.symtab.syms); > check (status == LDPS_OK, LDPL_FATAL, "could not add symbols"); > > - LOCK_SECTION; > - num_claimed_files++; > - claimed_files = > - xrealloc (claimed_files, > - num_claimed_files * sizeof (struct plugin_file_info)); > - claimed_files[num_claimed_files - 1] = lto_file; > - UNLOCK_SECTION; > + /* Include it only if it is known to be used for link output. */ > + if (known_used) > + { > + LOCK_SECTION; > + num_claimed_files++; > + claimed_files = > + xrealloc (claimed_files, > + num_claimed_files * sizeof (struct plugin_file_info)); > + claimed_files[num_claimed_files - 1] = lto_file; > + UNLOCK_SECTION; > + } > > - *claimed = 1; > + *can_be_claimed = 1; > } > > LOCK_SECTION; > @@ -1310,10 +1317,10 @@ claim_file_handler_v2 (const struct ld_plugin_input_file *file, int *claimed, > /* If this is an LTO file without offload, and it is the first LTO file, save > the pointer to the last offload file in the list. Further offload LTO > files will be inserted after it, if any. */ > - if (*claimed && !obj.offload && offload_files_last_lto == NULL) > + if (*can_be_claimed && !obj.offload && offload_files_last_lto == NULL) > offload_files_last_lto = offload_files_last; > > - if (obj.offload && (known_used || obj.found > 0)) > + if (obj.offload && known_used && obj.found > 0) > { > /* Add file to the list. The order must be exactly the same as the final > order after recompilation and linking, otherwise host and target tables > @@ -1324,7 +1331,9 @@ claim_file_handler_v2 (const struct ld_plugin_input_file *file, int *claimed, > ofld->name = lto_file.name; > ofld->next = NULL; > > - if (*claimed && offload_files_last_lto == NULL && file->offset != 0 > + if (*can_be_claimed > + && offload_files_last_lto == NULL > + && file->offset != 0 > && gold_version == -1) > { > /* ld only: insert first LTO file from the archive after the last real > @@ -1341,7 +1350,7 @@ claim_file_handler_v2 (const struct ld_plugin_input_file *file, int *claimed, > offload_files->next = ofld; > } > } > - else if (*claimed && offload_files_last_lto != NULL) > + else if (*can_be_claimed && offload_files_last_lto != NULL) > { > /* Insert LTO file after the last LTO file in the list. */ > ofld->next = offload_files_last_lto->next; > @@ -1356,7 +1365,7 @@ claim_file_handler_v2 (const struct ld_plugin_input_file *file, int *claimed, > offload_files_last = ofld; > if (file->offset == 0) > offload_files_last_obj = ofld; > - if (*claimed) > + if (*can_be_claimed) > offload_files_last_lto = ofld; > num_offload_files++; > } > -- > 2.46.0 >
> -----Original Message----- > From: Richard Biener <richard.guenther@gmail.com> > Sent: Thursday, August 22, 2024 2:16 PM > To: H.J. Lu <hjl.tools@gmail.com> > Cc: gcc-patches@gcc.gnu.org; josmyers@redhat.com > Subject: Re: [PATCH v3] Update LDPT_REGISTER_CLAIM_FILE_HOOK_V2 linker > plugin hook > > External email: Use caution opening links or attachments > > > On Wed, Aug 21, 2024 at 4:25 PM H.J. Lu <hjl.tools@gmail.com> wrote: > > > > This hook allows the BFD linker plugin to distinguish calls to > > claim_file_handler that know the object is being used by the linker > > (from ldmain.c:add_archive_element), from calls that don't know it's > > being used by the linker (from elf_link_is_defined_archive_symbol); > in > > the latter case, the plugin should avoid including the unused LTO > > archive members in link output. To get the proper support for > > archives with LTO common symbols, the linker fix > > OK. Hi, After this commit: https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=a98dd536b1017c2b814a3465206c6c01b2890998 I am no longer able to see mkoffload (and accel compiler) being invoked for nvptx (-save-temps also doesn't show accel dumps). I have attached -v output before and after the commit for x86_64->nvptx offloading for the following simple test (host doesn't really matter, can also reproduce with aarch64 host): int main() { int x = 1; #pragma omp target map(x) x = 5; return x; } Thanks, Prathamesh > > Thanks, > Richard. > > > commit a6f8fe0a9e9cbe871652e46ba7c22d5e9fb86208 > > Author: H.J. Lu <hjl.tools@gmail.com> > > Date: Wed Aug 14 20:50:02 2024 -0700 > > > > lto: Don't include unused LTO archive members in output > > > > is required. > > > > PR lto/116361 > > * lto-plugin.c (claim_file_handler_v2): Rename claimed to > > can_be_claimed. Include the LTO object only if it is known > to > > be included in link output. > > > > Signed-off-by: H.J. Lu <hjl.tools@gmail.com> > > --- > > lto-plugin/lto-plugin.c | 53 > > ++++++++++++++++++++++++----------------- > > 1 file changed, 31 insertions(+), 22 deletions(-) > > > > diff --git a/lto-plugin/lto-plugin.c b/lto-plugin/lto-plugin.c index > > 152648338b9..61b0de62f52 100644 > > --- a/lto-plugin/lto-plugin.c > > +++ b/lto-plugin/lto-plugin.c > > @@ -1191,16 +1191,19 @@ process_offload_section (void *data, const > char *name, off_t offset, off_t len) > > return 1; > > } > > > > -/* Callback used by a linker to check if the plugin will claim > FILE. Writes > > - the result in CLAIMED. If KNOWN_USED, the object is known by > the linker > > - to be used, or an older API version is in use that does not > provide that > > - information; otherwise, the linker is only determining whether > this is > > - a plugin object and it should not be registered as having > offload data if > > - not claimed by the plugin. */ > > +/* Callback used by a linker to check if the plugin can claim FILE. > > + Writes the result in CAN_BE_CLAIMED. If KNOWN_USED != 0, the > object > > + is known by the linker to be included in link output, or an > older API > > + version is in use that does not provide that information. > Otherwise, > > + the linker is only determining whether this is a plugin object > and > > + only the symbol table is needed by the linker. In this case, > the > > + object should not be included in link output and this function > will > > + be called by the linker again with KNOWN_USED != 0 after the > linker > > + decides the object should be included in link output. */ > > > > static enum ld_plugin_status > > -claim_file_handler_v2 (const struct ld_plugin_input_file *file, int > *claimed, > > - int known_used) > > +claim_file_handler_v2 (const struct ld_plugin_input_file *file, > > + int *can_be_claimed, int known_used) > > { > > enum ld_plugin_status status; > > struct plugin_objfile obj; > > @@ -1229,7 +1232,7 @@ claim_file_handler_v2 (const struct > ld_plugin_input_file *file, int *claimed, > > } > > lto_file.handle = file->handle; > > > > - *claimed = 0; > > + *can_be_claimed = 0; > > obj.file = file; > > obj.found = 0; > > obj.offload = false; > > @@ -1286,15 +1289,19 @@ claim_file_handler_v2 (const struct > ld_plugin_input_file *file, int *claimed, > > lto_file.symtab.syms); > > check (status == LDPS_OK, LDPL_FATAL, "could not add > symbols"); > > > > - LOCK_SECTION; > > - num_claimed_files++; > > - claimed_files = > > - xrealloc (claimed_files, > > - num_claimed_files * sizeof (struct > plugin_file_info)); > > - claimed_files[num_claimed_files - 1] = lto_file; > > - UNLOCK_SECTION; > > + /* Include it only if it is known to be used for link output. > */ > > + if (known_used) > > + { > > + LOCK_SECTION; > > + num_claimed_files++; > > + claimed_files = > > + xrealloc (claimed_files, > > + num_claimed_files * sizeof (struct > plugin_file_info)); > > + claimed_files[num_claimed_files - 1] = lto_file; > > + UNLOCK_SECTION; > > + } > > > > - *claimed = 1; > > + *can_be_claimed = 1; > > } > > > > LOCK_SECTION; > > @@ -1310,10 +1317,10 @@ claim_file_handler_v2 (const struct > ld_plugin_input_file *file, int *claimed, > > /* If this is an LTO file without offload, and it is the first > LTO file, save > > the pointer to the last offload file in the list. Further > offload LTO > > files will be inserted after it, if any. */ > > - if (*claimed && !obj.offload && offload_files_last_lto == NULL) > > + if (*can_be_claimed && !obj.offload && offload_files_last_lto == > > + NULL) > > offload_files_last_lto = offload_files_last; > > > > - if (obj.offload && (known_used || obj.found > 0)) > > + if (obj.offload && known_used && obj.found > 0) > > { > > /* Add file to the list. The order must be exactly the same > as the final > > order after recompilation and linking, otherwise host and > > target tables @@ -1324,7 +1331,9 @@ claim_file_handler_v2 (const > struct ld_plugin_input_file *file, int *claimed, > > ofld->name = lto_file.name; > > ofld->next = NULL; > > > > - if (*claimed && offload_files_last_lto == NULL && file- > >offset != 0 > > + if (*can_be_claimed > > + && offload_files_last_lto == NULL > > + && file->offset != 0 > > && gold_version == -1) > > { > > /* ld only: insert first LTO file from the archive after > the > > last real @@ -1341,7 +1350,7 @@ claim_file_handler_v2 (const struct > ld_plugin_input_file *file, int *claimed, > > offload_files->next = ofld; > > } > > } > > - else if (*claimed && offload_files_last_lto != NULL) > > + else if (*can_be_claimed && offload_files_last_lto != NULL) > > { > > /* Insert LTO file after the last LTO file in the list. > */ > > ofld->next = offload_files_last_lto->next; @@ -1356,7 > > +1365,7 @@ claim_file_handler_v2 (const struct ld_plugin_input_file > *file, int *claimed, > > offload_files_last = ofld; > > if (file->offset == 0) > > offload_files_last_obj = ofld; > > - if (*claimed) > > + if (*can_be_claimed) > > offload_files_last_lto = ofld; > > num_offload_files++; > > } > > -- > > 2.46.0 > > Using built-in specs. COLLECT_GCC=../../install/bin/gcc COLLECT_LTO_WRAPPER=/home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install/libexec/gcc/x86_64-pc-linux-gnu/15.0.0/lto-wrapper OFFLOAD_TARGET_NAMES=nvptx-none Target: x86_64-pc-linux-gnu Configured with: ../gcc/configure --disable-multilib --enable-offload-targets=nvptx-none=/home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install --with-cuda-driver-lib=/usr/local/cuda/lib64 --with-cuda-driver-include=/usr/local/cuda/include --disable-bootstrap --prefix=/home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install --disable-werror --enable-languages=c,c++,fortran,lto Thread model: posix Supported LTO compression algorithms: zlib gcc version 15.0.0 20240822 (experimental) (GCC) COLLECT_GCC_OPTIONS='-O2' '-fopenmp' '-save-temps' '-v' '-mtune=generic' '-march=x86-64' '-pthread' '-dumpdir' 'a-' /home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install/libexec/gcc/x86_64-pc-linux-gnu/15.0.0/cc1 -E -quiet -v -imultiarch x86_64-linux-gnu -D_REENTRANT t.c -mtune=generic -march=x86-64 -fopenmp -O2 -fpch-preprocess -o a-t.i ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu" ignoring nonexistent directory "/home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install/lib/gcc/x86_64-pc-linux-gnu/15.0.0/../../../../x86_64-pc-linux-gnu/include" #include "..." search starts here: #include <...> search starts here: /home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install/lib/gcc/x86_64-pc-linux-gnu/15.0.0/include /usr/local/include /home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install/include /home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install/lib/gcc/x86_64-pc-linux-gnu/15.0.0/include-fixed/x86_64-linux-gnu /home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install/lib/gcc/x86_64-pc-linux-gnu/15.0.0/include-fixed /usr/include/x86_64-linux-gnu /usr/include End of search list. COLLECT_GCC_OPTIONS='-O2' '-fopenmp' '-save-temps' '-v' '-mtune=generic' '-march=x86-64' '-pthread' '-dumpdir' 'a-' /home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install/libexec/gcc/x86_64-pc-linux-gnu/15.0.0/cc1 -fpreprocessed a-t.i -quiet -dumpdir a- -dumpbase t.c -dumpbase-ext .c -mtune=generic -march=x86-64 -O2 -version -fopenmp -o a-t.s GNU C17 (GCC) version 15.0.0 20240822 (experimental) (x86_64-pc-linux-gnu) compiled by GNU C version 11.4.0, GMP version 6.2.1, MPFR version 4.1.0, MPC version 1.2.1, isl version isl-0.24-GMP GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096 Compiler executable checksum: b673df1f444dc27add2c2e34eb545bbf COLLECT_GCC_OPTIONS='-O2' '-fopenmp' '-save-temps' '-v' '-mtune=generic' '-march=x86-64' '-pthread' '-dumpdir' 'a-' as -v --64 -o a-t.o a-t.s GNU assembler version 2.38 (x86_64-linux-gnu) using BFD version (GNU Binutils for Ubuntu) 2.38 COMPILER_PATH=/home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install/libexec/gcc/x86_64-pc-linux-gnu/15.0.0/:/home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install/libexec/gcc/x86_64-pc-linux-gnu/15.0.0/:/home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install/libexec/gcc/x86_64-pc-linux-gnu/:/home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install/lib/gcc/x86_64-pc-linux-gnu/15.0.0/:/home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install/lib/gcc/x86_64-pc-linux-gnu/ LIBRARY_PATH=/home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install/lib/gcc/x86_64-pc-linux-gnu/15.0.0/:/home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install/lib/gcc/x86_64-pc-linux-gnu/15.0.0/../../../../lib64/:/lib/x86_64-linux-gnu/:/lib/../lib64/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib64/:/home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install/lib/gcc/x86_64-pc-linux-gnu/15.0.0/../../../:/lib/:/usr/lib/ Reading specs from /home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install/lib/gcc/x86_64-pc-linux-gnu/15.0.0/../../../../lib64/libgomp.spec COLLECT_GCC_OPTIONS='-O2' '-fopenmp' '-save-temps' '-v' '-mtune=generic' '-march=x86-64' '-pthread' '-dumpdir' 'a.' /home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install/libexec/gcc/x86_64-pc-linux-gnu/15.0.0/collect2 -plugin /home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install/libexec/gcc/x86_64-pc-linux-gnu/15.0.0/liblto_plugin.so -plugin-opt=/home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install/libexec/gcc/x86_64-pc-linux-gnu/15.0.0/lto-wrapper -plugin-opt=-fresolution=a.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lpthread -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 /lib/x86_64-linux-gnu/crt1.o /lib/x86_64-linux-gnu/crti.o /home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install/lib/gcc/x86_64-pc-linux-gnu/15.0.0/crtbegin.o /home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install/lib/gcc/x86_64-pc-linux-gnu/15.0.0/crtoffloadbegin.o -L/home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install/lib/gcc/x86_64-pc-linux-gnu/15.0.0 -L/home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install/lib/gcc/x86_64-pc-linux-gnu/15.0.0/../../../../lib64 -L/lib/x86_64-linux-gnu -L/lib/../lib64 -L/usr/lib/x86_64-linux-gnu -L/usr/lib/../lib64 -L/home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install/lib/gcc/x86_64-pc-linux-gnu/15.0.0/../../.. a-t.o -lgomp -lgcc --push-state --as-needed -lgcc_s --pop-state -lpthread -lc -lgcc --push-state --as-needed -lgcc_s --pop-state /home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install/lib/gcc/x86_64-pc-linux-gnu/15.0.0/crtend.o /lib/x86_64-linux-gnu/crtn.o /home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install/lib/gcc/x86_64-pc-linux-gnu/15.0.0/crtoffloadend.o COLLECT_GCC_OPTIONS='-O2' '-fopenmp' '-save-temps' '-v' '-mtune=generic' '-march=x86-64' '-pthread' '-dumpdir' 'a.' Using built-in specs. COLLECT_GCC=../../install/bin/gcc COLLECT_LTO_WRAPPER=/home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install/libexec/gcc/x86_64-pc-linux-gnu/15.0.0/lto-wrapper OFFLOAD_TARGET_NAMES=nvptx-none Target: x86_64-pc-linux-gnu Configured with: ../gcc/configure --disable-multilib --enable-offload-targets=nvptx-none=/home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install --with-cuda-driver-lib=/usr/local/cuda/lib64 --with-cuda-driver-include=/usr/local/cuda/include --disable-bootstrap --prefix=/home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install --disable-werror --enable-languages=c,c++,fortran,lto Thread model: posix Supported LTO compression algorithms: zlib gcc version 15.0.0 20240822 (experimental) (GCC) COLLECT_GCC_OPTIONS='-O2' '-fopenmp' '-save-temps' '-v' '-mtune=generic' '-march=x86-64' '-pthread' '-dumpdir' 'a-' /home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install/libexec/gcc/x86_64-pc-linux-gnu/15.0.0/cc1 -E -quiet -v -imultiarch x86_64-linux-gnu -D_REENTRANT t.c -mtune=generic -march=x86-64 -fopenmp -O2 -fpch-preprocess -o a-t.i ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu" ignoring nonexistent directory "/home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install/lib/gcc/x86_64-pc-linux-gnu/15.0.0/../../../../x86_64-pc-linux-gnu/include" #include "..." search starts here: #include <...> search starts here: /home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install/lib/gcc/x86_64-pc-linux-gnu/15.0.0/include /usr/local/include /home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install/include /home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install/lib/gcc/x86_64-pc-linux-gnu/15.0.0/include-fixed/x86_64-linux-gnu /home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install/lib/gcc/x86_64-pc-linux-gnu/15.0.0/include-fixed /usr/include/x86_64-linux-gnu /usr/include End of search list. COLLECT_GCC_OPTIONS='-O2' '-fopenmp' '-save-temps' '-v' '-mtune=generic' '-march=x86-64' '-pthread' '-dumpdir' 'a-' /home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install/libexec/gcc/x86_64-pc-linux-gnu/15.0.0/cc1 -fpreprocessed a-t.i -quiet -dumpdir a- -dumpbase t.c -dumpbase-ext .c -mtune=generic -march=x86-64 -O2 -version -fopenmp -o a-t.s GNU C17 (GCC) version 15.0.0 20240822 (experimental) (x86_64-pc-linux-gnu) compiled by GNU C version 11.4.0, GMP version 6.2.1, MPFR version 4.1.0, MPC version 1.2.1, isl version isl-0.24-GMP GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096 Compiler executable checksum: b673df1f444dc27add2c2e34eb545bbf COLLECT_GCC_OPTIONS='-O2' '-fopenmp' '-save-temps' '-v' '-mtune=generic' '-march=x86-64' '-pthread' '-dumpdir' 'a-' as -v --64 -o a-t.o a-t.s GNU assembler version 2.38 (x86_64-linux-gnu) using BFD version (GNU Binutils for Ubuntu) 2.38 COMPILER_PATH=/home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install/libexec/gcc/x86_64-pc-linux-gnu/15.0.0/:/home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install/libexec/gcc/x86_64-pc-linux-gnu/15.0.0/:/home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install/libexec/gcc/x86_64-pc-linux-gnu/:/home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install/lib/gcc/x86_64-pc-linux-gnu/15.0.0/:/home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install/lib/gcc/x86_64-pc-linux-gnu/ LIBRARY_PATH=/home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install/lib/gcc/x86_64-pc-linux-gnu/15.0.0/:/home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install/lib/gcc/x86_64-pc-linux-gnu/15.0.0/../../../../lib64/:/lib/x86_64-linux-gnu/:/lib/../lib64/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib64/:/home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install/lib/gcc/x86_64-pc-linux-gnu/15.0.0/../../../:/lib/:/usr/lib/ Reading specs from /home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install/lib/gcc/x86_64-pc-linux-gnu/15.0.0/../../../../lib64/libgomp.spec COLLECT_GCC_OPTIONS='-O2' '-fopenmp' '-save-temps' '-v' '-mtune=generic' '-march=x86-64' '-pthread' '-dumpdir' 'a.' /home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install/libexec/gcc/x86_64-pc-linux-gnu/15.0.0/collect2 -plugin /home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install/libexec/gcc/x86_64-pc-linux-gnu/15.0.0/liblto_plugin.so -plugin-opt=/home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install/libexec/gcc/x86_64-pc-linux-gnu/15.0.0/lto-wrapper -plugin-opt=-fresolution=a.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lpthread -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 /lib/x86_64-linux-gnu/crt1.o /lib/x86_64-linux-gnu/crti.o /home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install/lib/gcc/x86_64-pc-linux-gnu/15.0.0/crtbegin.o /home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install/lib/gcc/x86_64-pc-linux-gnu/15.0.0/crtoffloadbegin.o -L/home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install/lib/gcc/x86_64-pc-linux-gnu/15.0.0 -L/home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install/lib/gcc/x86_64-pc-linux-gnu/15.0.0/../../../../lib64 -L/lib/x86_64-linux-gnu -L/lib/../lib64 -L/usr/lib/x86_64-linux-gnu -L/usr/lib/../lib64 -L/home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install/lib/gcc/x86_64-pc-linux-gnu/15.0.0/../../.. a-t.o -lgomp -lgcc --push-state --as-needed -lgcc_s --pop-state -lpthread -lc -lgcc --push-state --as-needed -lgcc_s --pop-state /home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install/lib/gcc/x86_64-pc-linux-gnu/15.0.0/crtend.o /lib/x86_64-linux-gnu/crtn.o /home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install/lib/gcc/x86_64-pc-linux-gnu/15.0.0/crtoffloadend.o /home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install/libexec/gcc/x86_64-pc-linux-gnu/15.0.0/lto-wrapper -fresolution=a.res -flinker-output=exec -foffload-objects=a.ofldlist /home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install/libexec/gcc/x86_64-pc-linux-gnu/15.0.0/lto-wrapper -fresolution=a.res -flinker-output=exec -foffload-objects=a.ofldlist [Leaving LTRANS a.ofldlist] /home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install/libexec/gcc/x86_64-pc-linux-gnu/15.0.0//accel/nvptx-none/mkoffload @./a.nvptx-none.offload_args GCC_OFFLOAD_OMP_REQUIRES_FILE=./a.xnvptx-none.mkoffload.omp_requires ../../install/bin/x86_64-pc-linux-gnu-accel-nvptx-none-gcc @./a.xnvptx-none.gcc_args Using built-in specs. COLLECT_GCC=../../install/bin/x86_64-pc-linux-gnu-accel-nvptx-none-gcc COLLECT_LTO_WRAPPER=/home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install/libexec/gcc/x86_64-pc-linux-gnu/15.0.0/accel/nvptx-none/lto-wrapper Target: nvptx-none Configured with: ../gcc/configure --prefix=/home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install --target=nvptx-none --with-arch=sm_70 --enable-as-accelerator-for=x86_64-pc-linux-gnu --disable-bootstrap --disable-werror --with-build-time-tools=/home/prathameshk/gnu-toolchain/nvptx-tools/install/bin --disable-sjlj-exceptions --enable-newlib-io-long-long --enable-languages=c,c++,fortran,lto Thread model: single Supported LTO compression algorithms: zlib gcc version 15.0.0 20240822 (experimental) (GCC) COLLECT_GCC_OPTIONS='-save-temps' '-v' '-m64' '-mgomp' '-save-temps' '-v' '-fno-openacc' '-fno-pie' '-fcf-protection=none' '-foffload-abi=lp64' '-O2' '-fopenmp' '-o' './a.xnvptx-none.mkoffload' '-misa=sm_70' /home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install/libexec/gcc/x86_64-pc-linux-gnu/15.0.0/accel/nvptx-none/lto1 -quiet -dumpbase ./a.xnvptx-none.mkoffload -m64 -mgomp -misa=sm_70 -O2 -version -fno-openacc -fno-pie -fcf-protection=none -foffload-abi=lp64 -fopenmp @./a.xnvptx-none.mkoffload.args.0 -o ./a.xnvptx-none.mkoffload.s GNU GIMPLE (GCC) version 15.0.0 20240822 (experimental) (nvptx-none) compiled by GNU C version 11.4.0, GMP version 6.2.1, MPFR version 4.1.0, MPC version 1.2.1, isl version isl-0.24-GMP GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096 COLLECT_GCC_OPTIONS='-save-temps' '-v' '-m64' '-mgomp' '-save-temps' '-v' '-fno-openacc' '-fno-pie' '-fcf-protection=none' '-foffload-abi=lp64' '-O2' '-fopenmp' '-o' './a.xnvptx-none.mkoffload' '-misa=sm_70' /home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install/libexec/gcc/x86_64-pc-linux-gnu/15.0.0/accel/nvptx-none/as -v -v -o ./a.xnvptx-none.mkoffload.o ./a.xnvptx-none.mkoffload.s ptxas -c -o /dev/null ./a.xnvptx-none.mkoffload.o --gpu-name sm_70 -O0 COMPILER_PATH=/home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install/libexec/gcc/x86_64-pc-linux-gnu/15.0.0/accel/nvptx-none/:/home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install/libexec/gcc/x86_64-pc-linux-gnu/15.0.0/accel/nvptx-none/:/home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install/libexec/gcc/nvptx-none/:/home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install/lib/gcc/x86_64-pc-linux-gnu/15.0.0/accel/nvptx-none/:/home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install/lib/gcc/nvptx-none/ LIBRARY_PATH=/home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install/lib/gcc/x86_64-pc-linux-gnu/15.0.0/accel/nvptx-none/mgomp/:/home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install/lib/gcc/x86_64-pc-linux-gnu/15.0.0/accel/nvptx-none/../../../../../../nvptx-none/lib/mgomp/:/home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install/lib/gcc/x86_64-pc-linux-gnu/15.0.0/accel/nvptx-none/:/home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install/lib/gcc/x86_64-pc-linux-gnu/15.0.0/accel/nvptx-none/../../../../../../nvptx-none/lib/ Reading specs from /home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install/lib/gcc/x86_64-pc-linux-gnu/15.0.0/accel/nvptx-none/../../../../../../nvptx-none/lib/mgomp/libgomp.spec COLLECT_GCC_OPTIONS='-save-temps' '-v' '-m64' '-mgomp' '-save-temps' '-v' '-fno-openacc' '-fno-pie' '-fcf-protection=none' '-foffload-abi=lp64' '-O2' '-fopenmp' '-o' './a.xnvptx-none.mkoffload' '-misa=sm_70' '-dumpdir' './a.xnvptx-none.mkoffload.' /home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install/libexec/gcc/x86_64-pc-linux-gnu/15.0.0/accel/nvptx-none/collect2 -o ./a.xnvptx-none.mkoffload -L/home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install/lib/gcc/x86_64-pc-linux-gnu/15.0.0/accel/nvptx-none/mgomp -L/home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install/lib/gcc/x86_64-pc-linux-gnu/15.0.0/accel/nvptx-none/../../../../../../nvptx-none/lib/mgomp -L/home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install/lib/gcc/x86_64-pc-linux-gnu/15.0.0/accel/nvptx-none -L/home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install/lib/gcc/x86_64-pc-linux-gnu/15.0.0/accel/nvptx-none/../../../../../../nvptx-none/lib @./a.xnvptx-none.mkoffload.args.1 -lgomp -lgcc -lc -lgcc COLLECT_GCC_OPTIONS='-save-temps' '-v' '-m64' '-mgomp' '-save-temps' '-v' '-fno-openacc' '-fno-pie' '-fcf-protection=none' '-foffload-abi=lp64' '-O2' '-fopenmp' '-o' './a.xnvptx-none.mkoffload' '-misa=sm_70' '-dumpdir' './a.xnvptx-none.mkoffload.' GCC_EXEC_PREFIX= COMPILER_PATH=/home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install/libexec/gcc/x86_64-pc-linux-gnu/15.0.0/:/home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install/libexec/gcc/x86_64-pc-linux-gnu/15.0.0/:/home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install/libexec/gcc/x86_64-pc-linux-gnu/:/home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install/lib/gcc/x86_64-pc-linux-gnu/15.0.0/:/home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install/lib/gcc/x86_64-pc-linux-gnu/ LIBRARY_PATH=/home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install/lib/gcc/x86_64-pc-linux-gnu/15.0.0/:/home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install/lib/gcc/x86_64-pc-linux-gnu/15.0.0/../../../../lib64/:/lib/x86_64-linux-gnu/:/lib/../lib64/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib64/:/home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install/lib/gcc/x86_64-pc-linux-gnu/15.0.0/../../../:/lib/:/usr/lib/ ../../install/bin/gcc @./a.xnvptx-none.gccnative_args Using built-in specs. COLLECT_GCC=../../install/bin/gcc OFFLOAD_TARGET_NAMES=nvptx-none Target: x86_64-pc-linux-gnu Configured with: ../gcc/configure --disable-multilib --enable-offload-targets=nvptx-none=/home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install --with-cuda-driver-lib=/usr/local/cuda/lib64 --with-cuda-driver-include=/usr/local/cuda/include --disable-bootstrap --prefix=/home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install --disable-werror --enable-languages=c,c++,fortran,lto Thread model: posix Supported LTO compression algorithms: zlib gcc version 15.0.0 20240822 (experimental) (GCC) COLLECT_GCC_OPTIONS='-save-temps' '-v' '-dumpdir' '' '-dumpbase' './a.xnvptx-none.c' '-dumpbase-ext' '.c' '-m64' '-c' '-o' './a.xnvptx-none.o' '-mtune=generic' '-march=x86-64' /home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install/libexec/gcc/x86_64-pc-linux-gnu/15.0.0/cc1 -E -quiet -v -imultiarch x86_64-linux-gnu -iprefix x86_64-pc-linux-gnu/15.0.0/ -isystem /home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install/lib/gcc/x86_64-pc-linux-gnu/15.0.0/include -isystem /home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install/lib/gcc/x86_64-pc-linux-gnu/15.0.0/include-fixed/x86_64-linux-gnu -isystem /home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install/lib/gcc/x86_64-pc-linux-gnu/15.0.0/include-fixed ./a.xnvptx-none.c -m64 -mtune=generic -march=x86-64 -fpch-preprocess -o ./a.xnvptx-none.i ignoring nonexistent directory "x86_64-pc-linux-gnu/15.0.0/include" ignoring nonexistent directory "x86_64-pc-linux-gnu/15.0.0/include-fixed/x86_64-linux-gnu" ignoring nonexistent directory "x86_64-pc-linux-gnu/15.0.0/include-fixed" ignoring nonexistent directory "x86_64-pc-linux-gnu/15.0.0/../../../../x86_64-pc-linux-gnu/include" ignoring nonexistent directory "../../lib/gcc/x86_64-pc-linux-gnu/15.0.0/include" ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu" ignoring nonexistent directory "../../include" ignoring nonexistent directory "../../lib/gcc/x86_64-pc-linux-gnu/15.0.0/include-fixed/x86_64-linux-gnu" ignoring nonexistent directory "../../lib/gcc/x86_64-pc-linux-gnu/15.0.0/include-fixed" ignoring nonexistent directory "../../lib/gcc/x86_64-pc-linux-gnu/15.0.0/../../../../x86_64-pc-linux-gnu/include" #include "..." search starts here: #include <...> search starts here: /home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install/lib/gcc/x86_64-pc-linux-gnu/15.0.0/include /home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install/lib/gcc/x86_64-pc-linux-gnu/15.0.0/include-fixed/x86_64-linux-gnu /home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install/lib/gcc/x86_64-pc-linux-gnu/15.0.0/include-fixed /usr/local/include /usr/include/x86_64-linux-gnu /usr/include End of search list. COLLECT_GCC_OPTIONS='-save-temps' '-v' '-m64' '-c' '-o' './a.xnvptx-none.o' '-mtune=generic' '-march=x86-64' /home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install/libexec/gcc/x86_64-pc-linux-gnu/15.0.0/cc1 -fpreprocessed ./a.xnvptx-none.i -quiet -dumpbase ./a.xnvptx-none.c -dumpbase-ext .c -m64 -mtune=generic -march=x86-64 -version -o ./a.xnvptx-none.s GNU C17 (GCC) version 15.0.0 20240822 (experimental) (x86_64-pc-linux-gnu) compiled by GNU C version 11.4.0, GMP version 6.2.1, MPFR version 4.1.0, MPC version 1.2.1, isl version isl-0.24-GMP GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096 Compiler executable checksum: b673df1f444dc27add2c2e34eb545bbf COLLECT_GCC_OPTIONS='-save-temps' '-v' '-m64' '-c' '-o' './a.xnvptx-none.o' '-mtune=generic' '-march=x86-64' as -v --64 -o ./a.xnvptx-none.o ./a.xnvptx-none.s GNU assembler version 2.38 (x86_64-linux-gnu) using BFD version (GNU Binutils for Ubuntu) 2.38 COMPILER_PATH=/home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install/libexec/gcc/x86_64-pc-linux-gnu/15.0.0/:/home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install/libexec/gcc/x86_64-pc-linux-gnu/15.0.0/:/home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install/libexec/gcc/x86_64-pc-linux-gnu/:/home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install/lib/gcc/x86_64-pc-linux-gnu/15.0.0/:/home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install/lib/gcc/x86_64-pc-linux-gnu/ LIBRARY_PATH=:/home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install/lib/gcc/x86_64-pc-linux-gnu/15.0.0/../../../../lib64/../lib64/:/lib/../lib64/../lib64/:/usr/lib/../lib64/../lib64/:/home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install/lib/gcc/x86_64-pc-linux-gnu/15.0.0/../../../../lib64/:/lib/x86_64-linux-gnu/:/lib/../lib64/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib64/:/lib/x86_64-linux-gnu/:/lib/../lib64/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib64/:/home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install/lib/gcc/x86_64-pc-linux-gnu/15.0.0/:/home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install/lib/gcc/x86_64-pc-linux-gnu/15.0.0/../../../../lib64/:/lib/x86_64-linux-gnu/:/lib/../lib64/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib64/:/home/prathameshk/gnu-toolchain/gcc/grcogcc-38/install/lib/gcc/x86_64-pc-linux-gnu/15.0.0/../../../:/lib/:/usr/lib/:../:/lib/:/usr/lib/ COLLECT_GCC_OPTIONS='-save-temps' '-v' '-m64' '-c' '-o' './a.xnvptx-none.o' '-mtune=generic' '-march=x86-64' '-dumpdir' './a.xnvptx-none.' [Leaving ./a.xnvptx-none.c] [Leaving ./a.xnvptx-none.mkoffload] [Leaving ./a.xnvptx-none.mkoffload.omp_requires] [Leaving a.lto_wrapper_args] [Leaving ./a.crtoffloadtable.o] [Leaving ./a.xnvptx-none.o] COLLECT_GCC_OPTIONS='-O2' '-fopenmp' '-save-temps' '-v' '-mtune=generic' '-march=x86-64' '-pthread' '-dumpdir' 'a.'
On Fri, Aug 23, 2024, 4:02 AM Prathamesh Kulkarni <prathameshk@nvidia.com> wrote: > > > > -----Original Message----- > > From: Richard Biener <richard.guenther@gmail.com> > > Sent: Thursday, August 22, 2024 2:16 PM > > To: H.J. Lu <hjl.tools@gmail.com> > > Cc: gcc-patches@gcc.gnu.org; josmyers@redhat.com > > Subject: Re: [PATCH v3] Update LDPT_REGISTER_CLAIM_FILE_HOOK_V2 linker > > plugin hook > > > > External email: Use caution opening links or attachments > > > > > > On Wed, Aug 21, 2024 at 4:25 PM H.J. Lu <hjl.tools@gmail.com> wrote: > > > > > > This hook allows the BFD linker plugin to distinguish calls to > > > claim_file_handler that know the object is being used by the linker > > > (from ldmain.c:add_archive_element), from calls that don't know it's > > > being used by the linker (from elf_link_is_defined_archive_symbol); > > in > > > the latter case, the plugin should avoid including the unused LTO > > > archive members in link output. To get the proper support for > > > archives with LTO common symbols, the linker fix > > > > OK. > Hi, > After this commit: > > https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=a98dd536b1017c2b814a3465206c6c01b2890998 > I am no longer able to see mkoffload (and accel compiler) being invoked > for nvptx (-save-temps also doesn't show accel dumps). > I have attached -v output before and after the commit for x86_64->nvptx > offloading for the following simple test (host doesn't really matter, can > also reproduce with aarch64 host): > Please open a bug report with exact steps to reproduce the issue. > int main() > { > int x = 1; > #pragma omp target map(x) > x = 5; > return x; > } > > Thanks, > Prathamesh > > > > Thanks, > > Richard. > > > > > commit a6f8fe0a9e9cbe871652e46ba7c22d5e9fb86208 > > > Author: H.J. Lu <hjl.tools@gmail.com> > > > Date: Wed Aug 14 20:50:02 2024 -0700 > > > > > > lto: Don't include unused LTO archive members in output > > > > > > is required. > > > > > > PR lto/116361 > > > * lto-plugin.c (claim_file_handler_v2): Rename claimed to > > > can_be_claimed. Include the LTO object only if it is known > > to > > > be included in link output. > > > > > > Signed-off-by: H.J. Lu <hjl.tools@gmail.com> > > > --- > > > lto-plugin/lto-plugin.c | 53 > > > ++++++++++++++++++++++++----------------- > > > 1 file changed, 31 insertions(+), 22 deletions(-) > > > > > > diff --git a/lto-plugin/lto-plugin.c b/lto-plugin/lto-plugin.c index > > > 152648338b9..61b0de62f52 100644 > > > --- a/lto-plugin/lto-plugin.c > > > +++ b/lto-plugin/lto-plugin.c > > > @@ -1191,16 +1191,19 @@ process_offload_section (void *data, const > > char *name, off_t offset, off_t len) > > > return 1; > > > } > > > > > > -/* Callback used by a linker to check if the plugin will claim > > FILE. Writes > > > - the result in CLAIMED. If KNOWN_USED, the object is known by > > the linker > > > - to be used, or an older API version is in use that does not > > provide that > > > - information; otherwise, the linker is only determining whether > > this is > > > - a plugin object and it should not be registered as having > > offload data if > > > - not claimed by the plugin. */ > > > +/* Callback used by a linker to check if the plugin can claim FILE. > > > + Writes the result in CAN_BE_CLAIMED. If KNOWN_USED != 0, the > > object > > > + is known by the linker to be included in link output, or an > > older API > > > + version is in use that does not provide that information. > > Otherwise, > > > + the linker is only determining whether this is a plugin object > > and > > > + only the symbol table is needed by the linker. In this case, > > the > > > + object should not be included in link output and this function > > will > > > + be called by the linker again with KNOWN_USED != 0 after the > > linker > > > + decides the object should be included in link output. */ > > > > > > static enum ld_plugin_status > > > -claim_file_handler_v2 (const struct ld_plugin_input_file *file, int > > *claimed, > > > - int known_used) > > > +claim_file_handler_v2 (const struct ld_plugin_input_file *file, > > > + int *can_be_claimed, int known_used) > > > { > > > enum ld_plugin_status status; > > > struct plugin_objfile obj; > > > @@ -1229,7 +1232,7 @@ claim_file_handler_v2 (const struct > > ld_plugin_input_file *file, int *claimed, > > > } > > > lto_file.handle = file->handle; > > > > > > - *claimed = 0; > > > + *can_be_claimed = 0; > > > obj.file = file; > > > obj.found = 0; > > > obj.offload = false; > > > @@ -1286,15 +1289,19 @@ claim_file_handler_v2 (const struct > > ld_plugin_input_file *file, int *claimed, > > > lto_file.symtab.syms); > > > check (status == LDPS_OK, LDPL_FATAL, "could not add > > symbols"); > > > > > > - LOCK_SECTION; > > > - num_claimed_files++; > > > - claimed_files = > > > - xrealloc (claimed_files, > > > - num_claimed_files * sizeof (struct > > plugin_file_info)); > > > - claimed_files[num_claimed_files - 1] = lto_file; > > > - UNLOCK_SECTION; > > > + /* Include it only if it is known to be used for link output. > > */ > > > + if (known_used) > > > + { > > > + LOCK_SECTION; > > > + num_claimed_files++; > > > + claimed_files = > > > + xrealloc (claimed_files, > > > + num_claimed_files * sizeof (struct > > plugin_file_info)); > > > + claimed_files[num_claimed_files - 1] = lto_file; > > > + UNLOCK_SECTION; > > > + } > > > > > > - *claimed = 1; > > > + *can_be_claimed = 1; > > > } > > > > > > LOCK_SECTION; > > > @@ -1310,10 +1317,10 @@ claim_file_handler_v2 (const struct > > ld_plugin_input_file *file, int *claimed, > > > /* If this is an LTO file without offload, and it is the first > > LTO file, save > > > the pointer to the last offload file in the list. Further > > offload LTO > > > files will be inserted after it, if any. */ > > > - if (*claimed && !obj.offload && offload_files_last_lto == NULL) > > > + if (*can_be_claimed && !obj.offload && offload_files_last_lto == > > > + NULL) > > > offload_files_last_lto = offload_files_last; > > > > > > - if (obj.offload && (known_used || obj.found > 0)) > > > + if (obj.offload && known_used && obj.found > 0) > > > { > > > /* Add file to the list. The order must be exactly the same > > as the final > > > order after recompilation and linking, otherwise host and > > > target tables @@ -1324,7 +1331,9 @@ claim_file_handler_v2 (const > > struct ld_plugin_input_file *file, int *claimed, > > > ofld->name = lto_file.name; > > > ofld->next = NULL; > > > > > > - if (*claimed && offload_files_last_lto == NULL && file- > > >offset != 0 > > > + if (*can_be_claimed > > > + && offload_files_last_lto == NULL > > > + && file->offset != 0 > > > && gold_version == -1) > > > { > > > /* ld only: insert first LTO file from the archive after > > the > > > last real @@ -1341,7 +1350,7 @@ claim_file_handler_v2 (const struct > > ld_plugin_input_file *file, int *claimed, > > > offload_files->next = ofld; > > > } > > > } > > > - else if (*claimed && offload_files_last_lto != NULL) > > > + else if (*can_be_claimed && offload_files_last_lto != NULL) > > > { > > > /* Insert LTO file after the last LTO file in the list. > > */ > > > ofld->next = offload_files_last_lto->next; @@ -1356,7 > > > +1365,7 @@ claim_file_handler_v2 (const struct ld_plugin_input_file > > *file, int *claimed, > > > offload_files_last = ofld; > > > if (file->offset == 0) > > > offload_files_last_obj = ofld; > > > - if (*claimed) > > > + if (*can_be_claimed) > > > offload_files_last_lto = ofld; > > > num_offload_files++; > > > } > > > -- > > > 2.46.0 > > > > >
On Fri, Aug 23, 2024 at 4:02 AM Prathamesh Kulkarni <prathameshk@nvidia.com> wrote: > > > > > -----Original Message----- > > From: Richard Biener <richard.guenther@gmail.com> > > Sent: Thursday, August 22, 2024 2:16 PM > > To: H.J. Lu <hjl.tools@gmail.com> > > Cc: gcc-patches@gcc.gnu.org; josmyers@redhat.com > > Subject: Re: [PATCH v3] Update LDPT_REGISTER_CLAIM_FILE_HOOK_V2 linker > > plugin hook > > > > External email: Use caution opening links or attachments > > > > > > On Wed, Aug 21, 2024 at 4:25 PM H.J. Lu <hjl.tools@gmail.com> wrote: > > > > > > This hook allows the BFD linker plugin to distinguish calls to > > > claim_file_handler that know the object is being used by the linker > > > (from ldmain.c:add_archive_element), from calls that don't know it's > > > being used by the linker (from elf_link_is_defined_archive_symbol); > > in > > > the latter case, the plugin should avoid including the unused LTO > > > archive members in link output. To get the proper support for > > > archives with LTO common symbols, the linker fix > > > > OK. > Hi, > After this commit: > https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=a98dd536b1017c2b814a3465206c6c01b2890998 > I am no longer able to see mkoffload (and accel compiler) being invoked for nvptx (-save-temps also doesn't show accel dumps). > I have attached -v output before and after the commit for x86_64->nvptx offloading for the following simple test (host doesn't really matter, can also reproduce with aarch64 host): Please try https://gcc.gnu.org/pipermail/gcc-patches/2024-August/661306.html > int main() > { > int x = 1; > #pragma omp target map(x) > x = 5; > return x; > } > > Thanks, > Prathamesh > > > > Thanks, > > Richard. > > > > > commit a6f8fe0a9e9cbe871652e46ba7c22d5e9fb86208 > > > Author: H.J. Lu <hjl.tools@gmail.com> > > > Date: Wed Aug 14 20:50:02 2024 -0700 > > > > > > lto: Don't include unused LTO archive members in output > > > > > > is required. > > > > > > PR lto/116361 > > > * lto-plugin.c (claim_file_handler_v2): Rename claimed to > > > can_be_claimed. Include the LTO object only if it is known > > to > > > be included in link output. > > > > > > Signed-off-by: H.J. Lu <hjl.tools@gmail.com> > > > --- > > > lto-plugin/lto-plugin.c | 53 > > > ++++++++++++++++++++++++----------------- > > > 1 file changed, 31 insertions(+), 22 deletions(-) > > > > > > diff --git a/lto-plugin/lto-plugin.c b/lto-plugin/lto-plugin.c index > > > 152648338b9..61b0de62f52 100644 > > > --- a/lto-plugin/lto-plugin.c > > > +++ b/lto-plugin/lto-plugin.c > > > @@ -1191,16 +1191,19 @@ process_offload_section (void *data, const > > char *name, off_t offset, off_t len) > > > return 1; > > > } > > > > > > -/* Callback used by a linker to check if the plugin will claim > > FILE. Writes > > > - the result in CLAIMED. If KNOWN_USED, the object is known by > > the linker > > > - to be used, or an older API version is in use that does not > > provide that > > > - information; otherwise, the linker is only determining whether > > this is > > > - a plugin object and it should not be registered as having > > offload data if > > > - not claimed by the plugin. */ > > > +/* Callback used by a linker to check if the plugin can claim FILE. > > > + Writes the result in CAN_BE_CLAIMED. If KNOWN_USED != 0, the > > object > > > + is known by the linker to be included in link output, or an > > older API > > > + version is in use that does not provide that information. > > Otherwise, > > > + the linker is only determining whether this is a plugin object > > and > > > + only the symbol table is needed by the linker. In this case, > > the > > > + object should not be included in link output and this function > > will > > > + be called by the linker again with KNOWN_USED != 0 after the > > linker > > > + decides the object should be included in link output. */ > > > > > > static enum ld_plugin_status > > > -claim_file_handler_v2 (const struct ld_plugin_input_file *file, int > > *claimed, > > > - int known_used) > > > +claim_file_handler_v2 (const struct ld_plugin_input_file *file, > > > + int *can_be_claimed, int known_used) > > > { > > > enum ld_plugin_status status; > > > struct plugin_objfile obj; > > > @@ -1229,7 +1232,7 @@ claim_file_handler_v2 (const struct > > ld_plugin_input_file *file, int *claimed, > > > } > > > lto_file.handle = file->handle; > > > > > > - *claimed = 0; > > > + *can_be_claimed = 0; > > > obj.file = file; > > > obj.found = 0; > > > obj.offload = false; > > > @@ -1286,15 +1289,19 @@ claim_file_handler_v2 (const struct > > ld_plugin_input_file *file, int *claimed, > > > lto_file.symtab.syms); > > > check (status == LDPS_OK, LDPL_FATAL, "could not add > > symbols"); > > > > > > - LOCK_SECTION; > > > - num_claimed_files++; > > > - claimed_files = > > > - xrealloc (claimed_files, > > > - num_claimed_files * sizeof (struct > > plugin_file_info)); > > > - claimed_files[num_claimed_files - 1] = lto_file; > > > - UNLOCK_SECTION; > > > + /* Include it only if it is known to be used for link output. > > */ > > > + if (known_used) > > > + { > > > + LOCK_SECTION; > > > + num_claimed_files++; > > > + claimed_files = > > > + xrealloc (claimed_files, > > > + num_claimed_files * sizeof (struct > > plugin_file_info)); > > > + claimed_files[num_claimed_files - 1] = lto_file; > > > + UNLOCK_SECTION; > > > + } > > > > > > - *claimed = 1; > > > + *can_be_claimed = 1; > > > } > > > > > > LOCK_SECTION; > > > @@ -1310,10 +1317,10 @@ claim_file_handler_v2 (const struct > > ld_plugin_input_file *file, int *claimed, > > > /* If this is an LTO file without offload, and it is the first > > LTO file, save > > > the pointer to the last offload file in the list. Further > > offload LTO > > > files will be inserted after it, if any. */ > > > - if (*claimed && !obj.offload && offload_files_last_lto == NULL) > > > + if (*can_be_claimed && !obj.offload && offload_files_last_lto == > > > + NULL) > > > offload_files_last_lto = offload_files_last; > > > > > > - if (obj.offload && (known_used || obj.found > 0)) > > > + if (obj.offload && known_used && obj.found > 0) > > > { > > > /* Add file to the list. The order must be exactly the same > > as the final > > > order after recompilation and linking, otherwise host and > > > target tables @@ -1324,7 +1331,9 @@ claim_file_handler_v2 (const > > struct ld_plugin_input_file *file, int *claimed, > > > ofld->name = lto_file.name; > > > ofld->next = NULL; > > > > > > - if (*claimed && offload_files_last_lto == NULL && file- > > >offset != 0 > > > + if (*can_be_claimed > > > + && offload_files_last_lto == NULL > > > + && file->offset != 0 > > > && gold_version == -1) > > > { > > > /* ld only: insert first LTO file from the archive after > > the > > > last real @@ -1341,7 +1350,7 @@ claim_file_handler_v2 (const struct > > ld_plugin_input_file *file, int *claimed, > > > offload_files->next = ofld; > > > } > > > } > > > - else if (*claimed && offload_files_last_lto != NULL) > > > + else if (*can_be_claimed && offload_files_last_lto != NULL) > > > { > > > /* Insert LTO file after the last LTO file in the list. > > */ > > > ofld->next = offload_files_last_lto->next; @@ -1356,7 > > > +1365,7 @@ claim_file_handler_v2 (const struct ld_plugin_input_file > > *file, int *claimed, > > > offload_files_last = ofld; > > > if (file->offset == 0) > > > offload_files_last_obj = ofld; > > > - if (*claimed) > > > + if (*can_be_claimed) > > > offload_files_last_lto = ofld; > > > num_offload_files++; > > > } > > > -- > > > 2.46.0 > > >
diff --git a/lto-plugin/lto-plugin.c b/lto-plugin/lto-plugin.c index 152648338b9..61b0de62f52 100644 --- a/lto-plugin/lto-plugin.c +++ b/lto-plugin/lto-plugin.c @@ -1191,16 +1191,19 @@ process_offload_section (void *data, const char *name, off_t offset, off_t len) return 1; } -/* Callback used by a linker to check if the plugin will claim FILE. Writes - the result in CLAIMED. If KNOWN_USED, the object is known by the linker - to be used, or an older API version is in use that does not provide that - information; otherwise, the linker is only determining whether this is - a plugin object and it should not be registered as having offload data if - not claimed by the plugin. */ +/* Callback used by a linker to check if the plugin can claim FILE. + Writes the result in CAN_BE_CLAIMED. If KNOWN_USED != 0, the object + is known by the linker to be included in link output, or an older API + version is in use that does not provide that information. Otherwise, + the linker is only determining whether this is a plugin object and + only the symbol table is needed by the linker. In this case, the + object should not be included in link output and this function will + be called by the linker again with KNOWN_USED != 0 after the linker + decides the object should be included in link output. */ static enum ld_plugin_status -claim_file_handler_v2 (const struct ld_plugin_input_file *file, int *claimed, - int known_used) +claim_file_handler_v2 (const struct ld_plugin_input_file *file, + int *can_be_claimed, int known_used) { enum ld_plugin_status status; struct plugin_objfile obj; @@ -1229,7 +1232,7 @@ claim_file_handler_v2 (const struct ld_plugin_input_file *file, int *claimed, } lto_file.handle = file->handle; - *claimed = 0; + *can_be_claimed = 0; obj.file = file; obj.found = 0; obj.offload = false; @@ -1286,15 +1289,19 @@ claim_file_handler_v2 (const struct ld_plugin_input_file *file, int *claimed, lto_file.symtab.syms); check (status == LDPS_OK, LDPL_FATAL, "could not add symbols"); - LOCK_SECTION; - num_claimed_files++; - claimed_files = - xrealloc (claimed_files, - num_claimed_files * sizeof (struct plugin_file_info)); - claimed_files[num_claimed_files - 1] = lto_file; - UNLOCK_SECTION; + /* Include it only if it is known to be used for link output. */ + if (known_used) + { + LOCK_SECTION; + num_claimed_files++; + claimed_files = + xrealloc (claimed_files, + num_claimed_files * sizeof (struct plugin_file_info)); + claimed_files[num_claimed_files - 1] = lto_file; + UNLOCK_SECTION; + } - *claimed = 1; + *can_be_claimed = 1; } LOCK_SECTION; @@ -1310,10 +1317,10 @@ claim_file_handler_v2 (const struct ld_plugin_input_file *file, int *claimed, /* If this is an LTO file without offload, and it is the first LTO file, save the pointer to the last offload file in the list. Further offload LTO files will be inserted after it, if any. */ - if (*claimed && !obj.offload && offload_files_last_lto == NULL) + if (*can_be_claimed && !obj.offload && offload_files_last_lto == NULL) offload_files_last_lto = offload_files_last; - if (obj.offload && (known_used || obj.found > 0)) + if (obj.offload && known_used && obj.found > 0) { /* Add file to the list. The order must be exactly the same as the final order after recompilation and linking, otherwise host and target tables @@ -1324,7 +1331,9 @@ claim_file_handler_v2 (const struct ld_plugin_input_file *file, int *claimed, ofld->name = lto_file.name; ofld->next = NULL; - if (*claimed && offload_files_last_lto == NULL && file->offset != 0 + if (*can_be_claimed + && offload_files_last_lto == NULL + && file->offset != 0 && gold_version == -1) { /* ld only: insert first LTO file from the archive after the last real @@ -1341,7 +1350,7 @@ claim_file_handler_v2 (const struct ld_plugin_input_file *file, int *claimed, offload_files->next = ofld; } } - else if (*claimed && offload_files_last_lto != NULL) + else if (*can_be_claimed && offload_files_last_lto != NULL) { /* Insert LTO file after the last LTO file in the list. */ ofld->next = offload_files_last_lto->next; @@ -1356,7 +1365,7 @@ claim_file_handler_v2 (const struct ld_plugin_input_file *file, int *claimed, offload_files_last = ofld; if (file->offset == 0) offload_files_last_obj = ofld; - if (*claimed) + if (*can_be_claimed) offload_files_last_lto = ofld; num_offload_files++; }
This hook allows the BFD linker plugin to distinguish calls to claim_file_handler that know the object is being used by the linker (from ldmain.c:add_archive_element), from calls that don't know it's being used by the linker (from elf_link_is_defined_archive_symbol); in the latter case, the plugin should avoid including the unused LTO archive members in link output. To get the proper support for archives with LTO common symbols, the linker fix commit a6f8fe0a9e9cbe871652e46ba7c22d5e9fb86208 Author: H.J. Lu <hjl.tools@gmail.com> Date: Wed Aug 14 20:50:02 2024 -0700 lto: Don't include unused LTO archive members in output is required. PR lto/116361 * lto-plugin.c (claim_file_handler_v2): Rename claimed to can_be_claimed. Include the LTO object only if it is known to be included in link output. Signed-off-by: H.J. Lu <hjl.tools@gmail.com> --- lto-plugin/lto-plugin.c | 53 ++++++++++++++++++++++++----------------- 1 file changed, 31 insertions(+), 22 deletions(-)