Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MSVC build fails owing to overly long build directory names #4226

Closed
tp-m opened this issue Sep 20, 2018 · 15 comments
Closed

MSVC build fails owing to overly long build directory names #4226

tp-m opened this issue Sep 20, 2018 · 15 comments

Comments

@tp-m
Copy link
Member

tp-m commented Sep 20, 2018

So I'm building gst-build on Windows, with glib as a subproject. The build fails with the following error message:

[1/1857] Compiling C object subprojects/glib/gio/tests/gdbus-object-manager-example/subprojects@glib@gio@tests@gdbus-object-manager-example@@libgdbus-example-objectmanager@sha/meson-generated_.._gdbus-example-objectmanager-generated.c.obj. FAILED: subprojects/glib/gio/tests/gdbus-object-manager-example/subprojects@glib@gio@tests@gdbus-object-manager-example@@libgdbus-example-objectmanager@sha/meson-generated_.._gdbus-example-objectmanager-generated.c.obj cl @subprojects/glib/gio/tests/gdbus-object-manager-example/subprojects@glib@gio@tests@gdbus-object-manager-example@@libgdbus-example-objectmanager@sha/meson-generated_.._gdbus-example-objectmanager-generated.c.obj.rsp subprojects/glib/gio/tests/gdbus-object-manager-example/gdbus-example-objectmanager-generated.c: fatal error C1041: cannot open program database 'subprojects\\glib\\gio\\tests\\gdbus-object-manager-example\\subprojects@glib@gio@tests@gdbus-object-manager-example@@libgdbus-example-objectmanager@sha\\meson-generated_.._gdbus-example-objectmanager-generated.c.pdb'; if multiple CL.EXE write to the same .PDB file, please use /FS

Turns out the problem is the overly long build directory paths here, exceeding the default 260 path limit.

The build works fine if I use c:\build as build directory instead.

I understand why these paths might be needed in the flat layout case, but Meson knows that we don't use a flat layout here, so I think it shouldn't be using these long cluttery paths in this case.

@tp-m tp-m added the gstreamer label Sep 20, 2018
@tp-m
Copy link
Member Author

tp-m commented Sep 20, 2018

cc @sarum9in

@dcbaker
Copy link
Member

dcbaker commented Sep 20, 2018

We've run into the in mesa as well.

@jpakkane
Copy link
Member

I thought we were already using response files for these but apparently we only do that for linker invocations.

@tp-m
Copy link
Member Author

tp-m commented Sep 20, 2018

I think response files are already being used (I remember being irritated by ninja -v not showing any details), but won't help. They help bypass the max command line length aiui.

It looks to me like the args make it fine to cl.exe but something somewhere then constructs an absolute path and that blows the default 260 char path limit. And Meson makes the paths much longer than they need to be in this case.

@sarum9in
Copy link
Contributor

So the problem is #3246.
This is the code that generates the target id, which is the major part of the name.

        name_part = self.name.replace('/', '@').replace('\\', '@')
        assert not has_path_sep(self.type_suffix())
        myid = name_part + self.type_suffix()
        if self.subdir:
            subdir_part = self.subdir.replace('/', '@').replace('\\', '@')
            myid = subdir_part + '@@' + myid

It was shorter in the past:

        base = self.name + self.type_suffix()
        if self.subproject == '':
            return base
        return self.subproject + '@@' + base

The problem with previous approach is that it did not allow same ids in different subdirectories. New approach takes this into account, but unfortunately it effectively doubles the name size.

I have a possible workaround in mind: let's hash subdir_part of id with some short stable hashing function (e.g. sha). So the code would effectively be

        name_part = self.name.replace('/', '@').replace('\\', '@')
        assert not has_path_sep(self.type_suffix())
        myid = name_part + self.type_suffix()
        if self.subdir:
            subdir_part = self.subdir.replace('/', '@').replace('\\', '@')
            myid = SOME_SHA_FUNC(subdir_part) + '@@' + myid

This will not look as nice unfortunately but will solve the problem.
Another option is to check the size of the subdir_part and hash it only if it exceeds N (e.g. 100) symbols. Or similar but for the whole id, which will provide more consistent experience.

Thoughts?

@tp-m
Copy link
Member Author

tp-m commented Sep 24, 2018

I don't mind the hash - and for me the paths are quite unwieldy anyway, so I don't think there's too much lost from an aesthetic point of view - perhaps an abbreviated/short hash would be enough here? (8 chars)

@xclaesse
Copy link
Member

On a related note, using a hash could be needed to uniquify target ID per install directory. See #4019 (comment).

@sarum9in
Copy link
Contributor

@tp-m I will prepare a patch today/tomorrow and create a PR. Let's give it a try if it works for your builds and see if we get any other feedback regarding more obfuscated IDs.

sarum9in pushed a commit to sarum9in/meson that referenced this issue Sep 25, 2018
Fixed-size hash makes paths shorter and prevents doubling of path length
because of subdir usage in target id: "subdir/id" would generate
"subdir/{subdir-without-slashes}@@id" target otherwise.

Closes mesonbuild#4226.
sarum9in pushed a commit to sarum9in/meson that referenced this issue Sep 25, 2018
Fixed-size hash makes paths shorter and prevents doubling of path length
because of subdir usage in target id: "subdir/id" would generate
"subdir/{subdir-without-slashes}@@id" target otherwise.

Closes mesonbuild#4226.
@sarum9in
Copy link
Contributor

@tp-m could you please try #4263 and comment if it works for you?

sarum9in pushed a commit to sarum9in/meson that referenced this issue Oct 1, 2018
Fixed-size hash makes paths shorter and prevents doubling of path length
because of subdir usage in target id: "subdir/id" would generate
"subdir/{subdir-without-slashes}@@id" target otherwise.

Export construct_id_from_path() to aid tests.
Add a separate unit test for this function to make sure it is not broken unexpectedly.

Closes mesonbuild#4226.
sarum9in pushed a commit to sarum9in/meson that referenced this issue Oct 1, 2018
Fixed-size hash makes paths shorter and prevents doubling of path length
because of subdir usage in target id: "subdir/id" would generate
"subdir/{subdir-without-slashes}@@id" target otherwise.

Export construct_id_from_path() to aid tests.
Add a separate unit test for this function to make sure it is not broken unexpectedly.

Closes mesonbuild#4226.
sarum9in pushed a commit to sarum9in/meson that referenced this issue Oct 1, 2018
Fixed-size hash makes paths shorter and prevents doubling of path length
because of subdir usage in target id: "subdir/id" would generate
"subdir/{subdir-without-slashes}@@id" target otherwise.

Export construct_id_from_path() to aid tests.
Add a separate unit test for this function to make sure it is not broken unexpectedly.

Closes mesonbuild#4226.
sarum9in pushed a commit to sarum9in/meson that referenced this issue Oct 3, 2018
Fixed-size hash makes paths shorter and prevents doubling of path length
because of subdir usage in target id: "subdir/id" would generate
"subdir/{subdir-without-slashes}@@id" target otherwise.

Export construct_id_from_path() to aid tests.
Add a separate unit test for this function to make sure it is not broken unexpectedly.

Base32 is safe for both case-insensitive filesystems and Visual Studio IDs.
It is also shorter than hex.

Closes mesonbuild#4226.
@jon-turney
Copy link
Member

@nirbheek
Copy link
Member

nirbheek commented Oct 3, 2018

Does setting the registry key mentioned in https://docs.microsoft.com/en-us/windows/desktop/fileio/naming-a-file#maximum-path-length-limitation help?

That does help, and it is also an option in the Python installer, but it only works on Windows 10 so we need to fix this either way.

gnomesysadmins pushed a commit to GNOME/glib that referenced this issue Oct 4, 2018
…xes #1556

When using glib as a meson subproject on Windows the build currently fails
due to too long paths during the build process. See
mesonbuild/meson#4226 for the upstream bug.

To work around the issue shorten the filenames of the generated gdbus files.
@lazka
Copy link
Contributor

lazka commented Oct 4, 2018

I've opened https://gitlab.gnome.org/GNOME/glib/merge_requests/370 in glib to work this around temporarily.

sarum9in pushed a commit to sarum9in/meson that referenced this issue Oct 16, 2018
Fixed-size hash makes paths shorter and prevents doubling of path length
because of subdir usage in target id: "subdir/id" would generate
"subdir/{subdir-without-slashes}@@id" target otherwise.

Export construct_id_from_path() to aid tests.
Add a separate unit test for this function to make sure it is not broken unexpectedly.

Base32 is safe for both case-insensitive filesystems and Visual Studio IDs.
It is also shorter than hex.

Closes mesonbuild#4226.
sarum9in pushed a commit to sarum9in/meson that referenced this issue Oct 16, 2018
Fixed-size hash makes paths shorter and prevents doubling of path length
because of subdir usage in target id: "subdir/id" would generate
"subdir/{subdir-without-slashes}@@id" target otherwise.

Export construct_id_from_path() to aid tests.
Add a separate unit test for this function to make sure it is not broken unexpectedly.

Closes mesonbuild#4226.
sarum9in pushed a commit to sarum9in/meson that referenced this issue Nov 22, 2018
Fixed-size hash makes paths shorter and prevents doubling of path length
because of subdir usage in target id: "subdir/id" would generate
"subdir/{subdir-without-slashes}@@id" target otherwise.

Export construct_id_from_path() to aid tests.
Add a separate unit test for this function to make sure it is not broken unexpectedly.

Closes mesonbuild#4226.
jpakkane pushed a commit that referenced this issue Nov 22, 2018
Fixed-size hash makes paths shorter and prevents doubling of path length
because of subdir usage in target id: "subdir/id" would generate
"subdir/{subdir-without-slashes}@@id" target otherwise.

Export construct_id_from_path() to aid tests.
Add a separate unit test for this function to make sure it is not broken unexpectedly.

Closes #4226.
@ghost
Copy link

ghost commented Apr 2, 2019

This issue still affects files generated by the Windows module for compiling Windows rc files. The build fails with the error:

C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(5040,39): error MSB4023: Cannot evaluate the item metadata "%(FullPath)". The item metadata "%(FullPath)" cannot be applied to the path "fedb06e@@Windows resource for file 'src_maintenance-utility_maintenance-utility.rc'@cus\Windows resource for file 'src_maintenance-utility_maintenance-utility.rc'.exe". C:\Users\omninull\projects\driver\subprojects\utilities\vs-projects\vs2015-x86_64-debug\src\maintenance-utility\fedb06e@@Windows resource for file 'src_maintenance-utility_maintenance-utility.rc'@cus\Windows resource for file 'src_maintenance-utility_maintenance-utility.rc'.exe

It seems that the Windows module wasn't updated when this change was made.

Additionally, I started attempting a simple fix but still ran into the path limit issue due to prepending "Windows resource for file " to the beginning of the name, causing a failure with a log file:

C:\Users\omninull\projects\driver\subprojects\utilities\vs-projects\vs2015-x86_64-debug\src\maintenance-utility\fedb06e@@Windows resource for file 'maintenance-utility.rc'@cus\Windows .E9BEDD92.tlog\Windows resource for file 'maintenance-utility.rc'.lastbuildstate

Granted, this could be fixed with some directory layout changes to my project, but it would be nice to not have to do that.

Note, this only occurs when building with a Visual Studio solution file. Building via ninja is fine.

tbeloqui pushed a commit to pexip/meson that referenced this issue Aug 22, 2019
Fixed-size hash makes paths shorter and prevents doubling of path length
because of subdir usage in target id: "subdir/id" would generate
"subdir/{subdir-without-slashes}@@id" target otherwise.

Export construct_id_from_path() to aid tests.
Add a separate unit test for this function to make sure it is not broken unexpectedly.

Closes mesonbuild#4226.
@braindevices
Copy link

still affected, I think meson need to watch the filename/path length and use hash for the ones exceed limit.

@romeoxbm
Copy link

romeoxbm commented Dec 1, 2023

Still affected as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants