Bug 412344

Summary: Problem setting mips flags with specific paths
Product: [Developer tools] valgrind Reporter: Chris Packham <judge.packham>
Component: generalAssignee: Julian Seward <jseward>
Status: RESOLVED FIXED    
Severity: normal CC: mips32r2
Priority: NOR    
Version First Reported In: 3.15 SVN   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:
Attachments: patch for configure.ac
patch for configure.ac

Description Chris Packham 2019-09-26 02:52:37 UTC
SUMMARY

Hi,

We have a bulid environment/CI system where we are cross-compiling valgrind for various architectures. Due to the way the CI system creates it's working directories such as ${os}-${arch} we end up with paths like /workspace/linux-mips64/output which are included as part of the sysroot when cross-compiling.

Our configure invocation ends up like this

CFLAGS='--sysroot=/workspace/linux-mips64/sysroot -g2 -gz  -mabi=64 -O0' \
    ./configure --target=mips64-unknown-linux-gnu \
                --host=mips64-unknown-linux-gnu \
                --build=x86_64-linux-gnu ...

This trips up the following grep in configure.ac

https://sourceware.org/git/?p=valgrind.git;a=blob;f=configure.ac;hb=HEAD#l1751

It matches the 'linux-mips64' and skips the code that sets FLAG_M32 and FLAG_M64.

STEPS TO REPRODUCE
1. create sysroot in a path with 'linux-mips64' as a component
2. run 
  CFLAGS='--sysroot=/workspace/linux-mips64/sysroot -g2 -gz  -mabi=64 -O0' \
    ./configure --target=mips64-unknown-linux-gnu \
                --host=mips64-unknown-linux-gnu \
                --build=x86_64-linux-gnu
3. check values for FLAG_M32 and FLAG_M64 in config.log

OBSERVED RESULT

FLAG_M32 and FLAG_M64 are not set

EXPECTED RESULT

FLAG_M32='-mips32 -mabi=32' FLAG_M64='-march=mips64r2 -mabi=64'


SOFTWARE/OS VERSIONS
Linux: debian "buster"

ADDITIONAL INFORMATION
Comment 1 Chris Packham 2019-09-26 02:54:07 UTC
I think the solution probably lies in updating the grep patterns to anchor on non-word boundaries (e.g. \b) but I'm not sure how portable that is.
Comment 2 Chris Packham 2019-09-26 04:16:40 UTC
Created attachment 122873 [details]
patch for configure.ac

The attached patch seems to work for me on a linux system
Comment 3 Chris Packham 2019-09-26 04:30:42 UTC
Created attachment 122874 [details]
patch for configure.ac

Found a second instance that needs the same fix. Updated patch attached