msys2 / MINGW-packages

Package scripts for MinGW-w64 targets to build under MSYS2.
https://packages.msys2.org
BSD 3-Clause "New" or "Revised" License
2.29k stars 1.22k forks source link

Erroneous paths in 'gcc --print-search-dirs' #9411

Open lempamo opened 3 years ago

lempamo commented 3 years ago

I was trying to install GTK4 from the repo using meson, but the build failed. After some further investigation, it turns out that the GCC I was using (which came from MSYS) had some library search paths set to the D drive.

Why is this the case, and how can I remove them?

Further details: https://github.com/mesonbuild/meson/issues/9127

install: C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/
programs: =C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/;C:/msys64/mingw64/bin/../lib/gcc/;C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/x86_64-w64-mingw32/10.3.0/;C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/
libraries: =C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/;C:/msys64/mingw64/bin/../lib/gcc/;C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/lib/x86_64-w64-mingw32/10.3.0/;C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/lib/../lib/;C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../x86_64-w64-mingw32/10.3.0/;C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../lib/;D:/a/_temp/msys/msys64/mingw64/x86_64-w64-mingw32/lib/x86_64-w64-mingw32/10.3.0/;D:/a/_temp/msys/msys64/mingw64/x86_64-w64-mingw32/lib/../lib/;C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/lib/;C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../;D:/a/_temp/msys/msys64/mingw64/x86_64-w64-mingw32/lib/
Biswa96 commented 3 years ago

Can you provide some more information? It will be easy to reproduce

The erroneous path D:/a/_temp/msys/ came from GitHub Actions CI setup. Other paths look normal.

jeremyd2019 commented 3 years ago

It's just that the build environment paths msys root D:/a/_temp/msys/msys64/ are leaking into the built gcc.

rubyFeedback commented 3 years ago

Interesting. But these paths don't confuse any compile-related aspects?

Failing to compile GTK4 is an issue though. I actually also had problems compiling it via meson; in my case I had missing symbols that somehow could not be found. Since I don't know windows that well I decided to skip it for now and re-try at some later point in the future.

revelator commented 3 years ago

try adding -fcommon to CFLAGS and see if the symbols are still missing ?.

acidtonic commented 3 years ago

This is effecting me in the linked issue above (#9615)

Somehow this path gets built into the code-generator step of gdlmm and fails trying to run m4.exe from that erroneous D-drive path.

pineapplemachine commented 3 years ago

I am also having a related issue. D:/a/_temp/msys/msys64 subdirectories are inexplicably in my gcc search paths, and this is making meson unusable. It is currently not possible to run meson setup because of this issue. Here are some relevant logs:

λ meson setup build
The Meson build system
Version: 0.59.2
Source dir: E:\Sync\Projects\raylib\test-2021-10
Build dir: E:\Sync\Projects\raylib\test-2021-10\build
Build type: native build
Project name: Test
Project version: undefined
C++ compiler for the host machine: c++ (gcc 10.3.0 "c++ (Rev5, Built by MSYS2 project) 10.3.0")
C++ linker for the host machine: c++ ld.bfd 2.36.1
Host machine cpu family: x86_64
Host machine cpu: x86_64
Build targets in project: 1

Found ninja-1.10.2 at C:\msys64\mingw64\bin\ninja.EXE
Generating targets:   0%|

Traceback (most recent call last):
  File "e:\python\python-3.8.2\lib\site-packages\mesonbuild\mesonmain.py", line 228, in run
    return options.run_func(options)
  File "e:\python\python-3.8.2\lib\site-packages\mesonbuild\msetup.py", line 281, in run
    app.generate()
  File "e:\python\python-3.8.2\lib\site-packages\mesonbuild\msetup.py", line 184, in generate
    self._generate(env)
  File "e:\python\python-3.8.2\lib\site-packages\mesonbuild\msetup.py", line 246, in _generate
    intr.backend.generate()
  File "e:\python\python-3.8.2\lib\site-packages\mesonbuild\backend\ninjabackend.py", line 546, in generate
    self.generate_target(t)
  File "e:\python\python-3.8.2\lib\site-packages\mesonbuild\backend\ninjabackend.py", line 883, in generate_target
    elem = self.generate_link(target, outname, final_obj_list, linker, pch_objects, stdlib_args=stdlib_args)
  File "e:\python\python-3.8.2\lib\site-packages\mesonbuild\backend\ninjabackend.py", line 3033, in generate_link
    dep_targets.extend(self.guess_external_link_dependencies(linker, target, commands, internal))
  File "e:\python\python-3.8.2\lib\site-packages\mesonbuild\backend\ninjabackend.py", line 2873, in guess_external_link_dependencies
    search_dirs = tuple(search_dirs) + tuple(linker.get_library_dirs(self.environment))
  File "e:\python\python-3.8.2\lib\site-packages\mesonbuild\compilers\mixins\clike.py", line 254, in get_library_dirs
    return self._get_library_dirs(env, elf_class).copy()
  File "e:\python\python-3.8.2\lib\site-packages\mesonbuild\compilers\mixins\clike.py", line 213, in _get_library_dirs
    dirs = self.get_compiler_dirs(env, 'libraries')
  File "e:\python\python-3.8.2\lib\site-packages\mesonbuild\compilers\mixins\gnu.py", line 283, in get_compiler_dirs
    return self._split_fetch_real_dirs(line.split('=', 1)[1])
  File "e:\python\python-3.8.2\lib\site-packages\mesonbuild\compilers\mixins\gnu.py", line 265, in _split_fetch_real_dirs
    if pobj.exists():
  File "e:\python\python-3.8.2\lib\pathlib.py", line 1383, in exists
    self.stat()
  File "e:\python\python-3.8.2\lib\pathlib.py", line 1189, in stat
    return self._accessor.stat(self)
OSError: [WinError 87] The parameter is incorrect: 'D:\\a\\_temp\\msys\\msys64\\mingw64\\x86_64-w64-mingw32\\lib\\x86_64-w64-mingw32\\10.3.0'

λ g++ -print-search-dirs
install: C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/ programs: =C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/;C:/msys64/mingw64/bin/../lib/gcc/;C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/x86_64-w64-mingw32/10.3.0/;C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/
libraries: =C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/;C:/msys64/mingw64/bin/../lib/gcc/;C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/lib/x86_64-w64-mingw32/10.3.0/;C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/lib/../lib/;C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../x86_64-w64-mingw32/10.3.0/;C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../lib/;D:/a/_temp/msys/msys64/mingw64/x86_64-w64-mingw32/lib/x86_64-w64-mingw32/10.3.0/;D:/a/_temp/msys/msys64/mingw64/x86_64-w64-mingw32/lib/../lib/;C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/lib/;C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../;D:/a/_temp/msys/msys64/mingw64/x86_64-w64-mingw32/lib/
JohannesBe commented 5 months ago

Having the same issue;

The Meson build system
Version: 1.4.0
Source dir: G:/code/slv-cpp
Build dir: G:/code/slv-cpp/build-gcc
Build type: native build
Project name: slv
Project version: 1.0.0
C++ compiler for the host machine: c++ (gcc 14.1.0 "c++ (Rev3, Built by MSYS2 project) 14.1.0")
C++ linker for the host machine: c++ ld.bfd 2.42
Host machine cpu family: x86_64
Host machine cpu: x86_64
Message: Compiler: GCC
Program ld found: YES (G:\msys64\mingw64\bin/ld.EXE)
Build targets in project: 2
slv 1.0.0

  User defined options
    debug: true

Found ninja-1.12.0 at G:\msys64\mingw64\bin/ninja.EXE
OrderedSet()
Traceback (most recent call last):
  File "G:/msys64/mingw64/lib/python3.11/site-packages/mesonbuild/mesonmain.py", line 186, in run
    return options.run_func(options)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "G:/msys64/mingw64/lib/python3.11/site-packages/mesonbuild/msetup.py", line 363, in run
    app.generate()
  File "G:/msys64/mingw64/lib/python3.11/site-packages/mesonbuild/msetup.py", line 187, in generate
    return self._generate(env, capture, vslite_ctx)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "G:/msys64/mingw64/lib/python3.11/site-packages/mesonbuild/msetup.py", line 251, in _generate
    captured_compile_args = intr.backend.generate(capture, vslite_ctx)
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "G:/msys64/mingw64/lib/python3.11/site-packages/mesonbuild/backend/ninjabackend.py", line 620, in generate
    self.generate_target(t)
  File "G:/msys64/mingw64/lib/python3.11/site-packages/mesonbuild/backend/ninjabackend.py", line 1044, in generate_target
    elem = self.generate_link(target, outname, final_obj_list, linker, pch_objects, stdlib_args=stdlib_args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "G:/msys64/mingw64/lib/python3.11/site-packages/mesonbuild/backend/ninjabackend.py", line 3497, in generate_link
    dep_targets.extend(self.guess_external_link_dependencies(linker, target, commands, internal))
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "G:/msys64/mingw64/lib/python3.11/site-packages/mesonbuild/backend/ninjabackend.py", line 3336, in guess_external_link_dependencies
    search_dirs = tuple(search_dirs) + tuple(linker.get_library_dirs(self.environment))
                                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "G:/msys64/mingw64/lib/python3.11/site-packages/mesonbuild/compilers/mixins/clike.py", line 247, in get_library_dirs
    return self._get_library_dirs(env, elf_class).copy()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "G:/msys64/mingw64/lib/python3.11/site-packages/mesonbuild/compilers/mixins/clike.py", line 206, in _get_library_dirs
    dirs = self.get_compiler_dirs(env, 'libraries')
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "G:/msys64/mingw64/lib/python3.11/site-packages/mesonbuild/compilers/mixins/gnu.py", line 491, in get_compiler_dirs
    return self._split_fetch_real_dirs(line.split('=', 1)[1])
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "G:/msys64/mingw64/lib/python3.11/site-packages/mesonbuild/compilers/mixins/gnu.py", line 473, in _split_fetch_real_dirs
    if pobj.exists():
       ^^^^^^^^^^^^^
  File "G:/msys64/mingw64/lib/python3.11/pathlib.py", line 1237, in exists
    self.stat()
  File "G:/msys64/mingw64/lib/python3.11/pathlib.py", line 1015, in stat
    return os.stat(self, follow_symlinks=follow_symlinks)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
OSError: [WinError 87] The parameter is incorrect: 'D:/a/msys64/mingw64/lib/x86_64-w64-mingw32/14.1.0'

and if I do gcc --print-search-dirs:

install: G:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.1.0/
programs: =
    G:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.1.0/;
    G:/msys64/mingw64/bin/../lib/gcc/;
    G:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.1.0/../../../../x86_64-w64-mingw32/bin/x86_64-w64-mingw32/14.1.0/;
    G:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.1.0/../../../../x86_64-w64-mingw32/bin/
libraries: =
    G:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.1.0/;
    G:/msys64/mingw64/bin/../lib/gcc/;
    G:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.1.0/../../../../x86_64-w64-mingw32/lib/x86_64-w64-mingw32/14.1.0/;
    G:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.1.0/../../../../x86_64-w64-mingw32/lib/../lib/;
    G:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.1.0/../../../x86_64-w64-mingw32/14.1.0/;
    G:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.1.0/../../../../lib/;
    D:/a/msys64/mingw64/lib/x86_64-w64-mingw32/14.1.0/;
    D:/a/msys64/mingw64/lib/../lib/;
    G:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.1.0/../../../../x86_64-w64-mingw32/lib/;
    G:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.1.0/../../../;
    D:/a/msys64/mingw64/lib/

The weird thing is, I don't even have a D drive...