On 08/15/2017 02:45 PM, Martin Liška wrote: > Hi. > > As shown in the PR, remove_prefix function is written wrongly. It does not distinguish > in between a node in linked list and pprefix->plist. So I decide to rewrite it. > Apart from that, I identified discrepancy in between do_add_prefix and prefix_from_string > where the later one appends always DIR_SEPARATOR (if missing). So I also the former function. > And I'm adding unit tests for all functions in file-find.c. > > Patch can bootstrap on ppc64le-redhat-linux and survives regression tests. > > Ready to be installed? > Martin > > gcc/ChangeLog: > > 2017-08-14 Martin Liska > > PR driver/81829 > * file-find.c (do_add_prefix): Always append DIR_SEPARATOR > at the end of a prefix. > (remove_prefix): Properly remove elements and accept also > path without a trailing DIR_SEPARATOR. > (purge): New function. > (file_find_verify_prefix_creation): Likewise. > (file_find_verify_prefix_add): Likewise. > (file_find_verify_prefix_removal): Likewise. > (file_find_c_tests): Likewise. > * selftest-run-tests.c (selftest::run_tests): Add new > file_find_c_tests. > * selftest.h (file_find_c_tests): Likewise. > --- > gcc/file-find.c | 182 ++++++++++++++++++++++++++++++++++++++++++----- > gcc/selftest-run-tests.c | 1 + > gcc/selftest.h | 1 + > 3 files changed, 167 insertions(+), 17 deletions(-) > > Hi. As doko pointed out, the first version was not correct. Let me describe 2 scenarios which should be supported: 1) my original motivation where I configure gcc w/ --prefix=/my_bin and I manually create in /my_bin/bin: $ ln -s gcc-ar ar $ ln -s gcc-nm nm $ ln -s gcc-ranlib ranlib and then is set PATH=/my_bin/bin:... and LD_LIBRARY_PATH and I don't have to care about NM=gcc-nm and so on. That's how I usually test a newly built GCC. 2) using NM=gcc-nm and so on will force usage of LTO plugin. That's what was broken in first version of the patch. In order to support both cases we need to identify real name of GCC wrapper (like /my_bin/bin/gcc-ar) and when find_a_file (&path, real_exe_name, X_OK) will point to the same file, the directory should be ignored from prefix. Can you please test attached patch in your scenario? Thanks, Martin