Repository: mesonbuild/meson

Issue:
test_order_of_l_arguments fails on Fedora Rawhide
```python
======================================================================
FAIL: test_order_of_l_arguments (__main__.LinuxlikeTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "run_unittests.py", line 1772, in test_order_of_l_arguments
    self.assertLess(previous_index, current_index)
AssertionError: 85 not less than 78
Stdout:
The Meson build system
Version: 0.41.0
Source dir: /builddir/build/BUILD/meson-0.41.0/test cases/unit/9 -L -l order
Build dir: /tmp/tmpxs97a85i
Build type: native build
Project name: jonne
Native c compiler: cc (gcc 7.1.1)
Build machine cpu family: ppc64le
Build machine cpu: ppc64le
Found pkg-config: /usr/bin/pkg-config (1.3.7)
Native dependency first found: YES 1.0.0
Native dependency second found: YES 1.0.0
Build targets in project: 1
----------------------------------------------------------------------
Ran 53 tests in 39.639s
FAILED (failures=1, skipped=7)
```


Discussion:
Can you run the test manually and show us what the linker commandline looks like? You have to just run `PKG_CONFIG_PATH=$PWD meson build`.
```
build lprog: c_LINKER lprog@exe/prog.c.o
 LINK_ARGS = -Wl,--no-undefined -Wl,--as-needed -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic -Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -L/me/first -Wl,--start-group -lfoo1 -L/me/second -lfoo2 -L/me/third -lfoo3 -L/me/fourth -lfoo4 -Wl,--end-group
```
```
$ pkg-config --version
1.3.7
```

P.S. in Fedora we use [pkgconf](https://github.com/pkgconf/pkgconf) nowadays
looks like it just finds `-L/me/second` and `-lfoo1`
Comment in the unit test for this:

        # NOTE: .pc file has -Lfoo -lfoo -Lbar -lbar but pkg-config reorders
        # the flags before returning them to -Lfoo -Lbar -lfoo -lbar


Resolving patch:
diff --git a/run_unittests.py b/run_unittests.py
--- a/run_unittests.py
+++ b/run_unittests.py
@@ -1770,16 +1770,22 @@ def test_order_of_l_arguments(self):
         self.init(testdir)
         # NOTE: .pc file has -Lfoo -lfoo -Lbar -lbar but pkg-config reorders
         # the flags before returning them to -Lfoo -Lbar -lfoo -lbar
-        expected_order = ['-L/me/first', '-L/me/second','-lfoo1', '-lfoo2',
-                          '-L/me/third', '-L/me/fourth', '-lfoo3', '-lfoo4']
+        # but pkgconf seems to not do that. Sigh. Support both.
+        expected_order = [('-L/me/first', '-lfoo1'),
+                          ('-L/me/second', '-lfoo2'),
+                          ('-L/me/first', '-L/me/second'),
+                          ('-lfoo1', '-lfoo2'),
+                          ('-L/me/second', '-L/me/third'),
+                          ('-L/me/third', '-L/me/fourth',),
+                          ('-L/me/third', '-lfoo3'),
+                          ('-L/me/fourth', '-lfoo4'),
+                          ('-lfoo3', '-lfoo4'),
+                          ]
         with open(os.path.join(self.builddir, 'build.ninja')) as ifile:
             for line in ifile:
-                if expected_order[0] in line:
-                    previous_index = line.index(expected_order[0])
-                    for entry in expected_order[1:]:
-                        current_index = line.index(entry)
-                        self.assertLess(previous_index, current_index)
-                        previous_index = current_index
+                if expected_order[0][0] in line:
+                    for first, second in expected_order:
+                        self.assertLess(line.index(first), line.index(second))
                     return
         raise RuntimeError('Linker entries not found in the Ninja file.')
 


Test patch: