Skip to content
New issue

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

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

Already on GitHub? # to your account

[libflac] Build error on x64-windows #43176

Open
junkoya opened this issue Jan 9, 2025 · 5 comments
Open

[libflac] Build error on x64-windows #43176

junkoya opened this issue Jan 9, 2025 · 5 comments
Assignees
Labels
requires:repro The issue is not currently repro-able

Comments

@junkoya
Copy link

junkoya commented Jan 9, 2025

Package: libflac[core,stack-protector]:x64-windows@1.4.3#2

Host Environment

  • Host: x64-windows
  • Compiler: MSVC 19.42.34435.0
  • vcpkg-tool version: 2024-12-09-1005b78fa1bf1dde1a20c2734cba4ea61ca94d9a
    vcpkg-scripts version: a3a2cda 2025-01-08 (8 hours ago)

To Reproduce

vcpkg install

Failure logs

-- Using cached xiph-flac-1.4.3.tar.gz.
-- Extracting source D:/vcpkg/downloads/xiph-flac-1.4.3.tar.gz
CMake Error at scripts/cmake/vcpkg_execute_required_process.cmake:127 (message):
    Command failed: "C:/Program Files/CMake/bin/cmake.exe" -E tar xjf D:/vcpkg/downloads/xiph-flac-1.4.3.tar.gz
    Working Directory: D:/vcpkg/buildtrees/libflac/src/1.4.3-00043104ae.clean.tmp
    Error code: 1
    See logs for more information:
      D:\vcpkg\buildtrees\libflac\extract-err.log

Call Stack (most recent call first):
  scripts/cmake/vcpkg_extract_source_archive.cmake:120 (vcpkg_execute_required_process)
  scripts/cmake/vcpkg_extract_source_archive_ex.cmake:8 (vcpkg_extract_source_archive)
  scripts/cmake/vcpkg_from_github.cmake:113 (vcpkg_extract_source_archive_ex)
  ports/libflac/portfile.cmake:1 (vcpkg_from_github)
  scripts/ports.cmake:196 (include)



D:\vcpkg\buildtrees\libflac\extract-err.log
CMake Error: Problem with archive_write_header(): Invalid empty pathname
CMake Error: Current file: 
CMake Error: Problem extracting tar: D:/vcpkg/downloads/xiph-flac-1.4.3.tar.gz

Additional context

vcpkg.json
{
  "dependencies": [
    "libflac"
  ]
}

@LilyWangLL LilyWangLL added the requires:repro The issue is not currently repro-able label Jan 9, 2025
@LilyWangLL
Copy link
Contributor

Duplicate of issue #42804, please try the solution #42804 (comment):

Yes, vcpkg has updated the tools that need to be downloaded. The solution is that you need to re-run the ./bootstrap-vcpkg.bat script to update the vcpkg tools after updating the vcpkg library.

@junkoya
Copy link
Author

junkoya commented Jan 9, 2025

Thank you. But I found the comment you show. Before I made my issue, I removed all files in $VCPKG_ROOT folder, and re-ran from "git clone" (of course ./bootstrap-vcpkg.bat too)...

@junkoya
Copy link
Author

junkoya commented Jan 10, 2025

Package: libflac[core,stack-protector]:x64-windows@1.4.3#2

Host Environment

  • Host: x64-windows
  • Compiler: MSVC 19.42.34435.0
  • vcpkg-tool version: 2024-12-09-1005b78fa1bf1dde1a20c2734cba4ea61ca94d9a
    vcpkg-scripts version: 81ab9a8 2025-01-10 (10 hours ago)

To Reproduce

vcpkg install

Failure logs

-- Using cached xiph-flac-1.4.3.tar.gz.
-- Extracting source D:/vcpkg/downloads/xiph-flac-1.4.3.tar.gz
CMake Error at scripts/cmake/vcpkg_execute_required_process.cmake:127 (message):
    Command failed: "C:/Program Files/CMake/bin/cmake.exe" -E tar xjf D:/vcpkg/downloads/xiph-flac-1.4.3.tar.gz
    Working Directory: D:/vcpkg/buildtrees/libflac/src/1.4.3-00043104ae.clean.tmp
    Error code: 1
    See logs for more information:
      D:\vcpkg\buildtrees\libflac\extract-err.log

Call Stack (most recent call first):
  scripts/cmake/vcpkg_extract_source_archive.cmake:120 (vcpkg_execute_required_process)
  scripts/cmake/vcpkg_extract_source_archive_ex.cmake:8 (vcpkg_extract_source_archive)
  scripts/cmake/vcpkg_from_github.cmake:113 (vcpkg_extract_source_archive_ex)
  ports/libflac/portfile.cmake:1 (vcpkg_from_github)
  scripts/ports.cmake:196 (include)



D:\vcpkg\buildtrees\libflac\extract-err.log
CMake Error: Problem with archive_write_header(): Invalid empty pathname
CMake Error: Current file: 
CMake Error: Problem extracting tar: D:/vcpkg/downloads/xiph-flac-1.4.3.tar.gz

Additional context

vcpkg.json
{
  "dependencies": [
    "libflac"
  ]
}

@SausageTaste
Copy link

Hello!

I'm having a same issue as yours while installing ktx library.
I've been investigating the issue and found out it's rather a bug in CMake code.

The source of problem is that cmake -E tar x command cannot extract files with Unicode names properly.

Your error message says:

Command failed: "C:/Program Files/CMake/bin/cmake.exe" -E tar xjf D:/vcpkg/downloads/xiph-flac-1.4.3.tar.gz

You can modify the command string to produce some verbose log messages:

cmake -E tar xv D:/vcpkg/downloads/xiph-flac-1.4.3.tar.gz

Then the output is following:

x flac-1.4.3/test/flac-to-flac-metadata-test-files/case04d-expect.meta
x flac-1.4.3/test/flac-to-flac-metadata-test-files/case04e-expect.meta
x flac-1.4.3/test/flac-to-flac-metadata-test-files/input-SCPAP.flac
x flac-1.4.3/test/flac-to-flac-metadata-test-files/input-SCVA.flac
x flac-1.4.3/test/flac-to-flac-metadata-test-files/input-SCVAUP.flac
x flac-1.4.3/test/flac-to-flac-metadata-test-files/input-SCVPAP.flac
x flac-1.4.3/test/flac-to-flac-metadata-test-files/input-SVAUP.flac
x flac-1.4.3/test/flac-to-flac-metadata-test-files/input-VA.flac
x flac-1.4.3/test/flac-to-flac-metadata-test-files/input0.cue
x
CMake Error: Problem with archive_write_header(): Invalid empty pathname
CMake Error: Current file:
CMake Error: Problem extracting tar: C:/Users/Administrator/Documents/GitHub/vcpkg/downloads/xiph-flac-1.4.3.tar.gz

It seems right after extracting input0.cue the process stopped.
Let's see what is there...

Image

Yes!
There are Unicode file names.

In CMake source archive_string.c

static int
archive_wstring_append_from_mbs_in_codepage(struct archive_wstring *dest,
    const char *s, size_t length, struct archive_string_conv *sc)
{
	...

	// In some systems `sc` is NULL
	if (sc != NULL)
		from_cp = sc->from_cp;
	else
		// My system locale is Korean so this becomes 949, meaning CP949 text encoding
		from_cp = get_current_codepage();

	if (from_cp == CP_C_LOCALE) {
		...
	} else if (sc != NULL &&
		...
	} else if (sc != NULL && (sc->flag & SCONV_FROM_UTF16)) {
		...
	} else {
		...
			// This fails because `from_cp` is CP949.
			count = MultiByteToWideChar(from_cp,
			    mbflag, s, (int)length, dest->s + dest->length,
			    (int)(dest->buffer_length >> 1) -1);
			if (count == 0 &&
			    GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
				/* Expand the WCS buffer. */
				buffsize = dest->buffer_length << 1;
				continue;
			}
			if (count == 0 && length != 0)
				ret = -1;
			break;
		} while (1);
	}
	dest->length += count;
	dest->s[dest->length] = L'\0';
	return (ret);
}

This function determines source text encoding and stores it in variable from_cp.
If struct archive_string_conv *sc is not NULL, that info is used, otherwise get_current_codepage() is used.
On my computer with Windows 10, Korean system locale and Korean UI, get_current_codepage() returns 949, which is CP949 text encoding.
This may be different on your system.
The problem here is, MultiByteToWideChar fails to convert the string because it's not in CP949, but UTF-8.

Image

error, the result of GetLastError(), is 1113, which means ERROR_NO_UNICODE_TRANSLATION.
Note that the source string s contains some gibberish characters.

I forced to use UTF-8 by setting cp_from to CP_UTF8 and the extraction succeeded without any error.

...
x flac-1.4.3/test/flac-to-flac-metadata-test-files/case04d-expect.meta
x flac-1.4.3/test/flac-to-flac-metadata-test-files/case04e-expect.meta
x flac-1.4.3/test/flac-to-flac-metadata-test-files/input-SCPAP.flac
x flac-1.4.3/test/flac-to-flac-metadata-test-files/input-SCVA.flac
x flac-1.4.3/test/flac-to-flac-metadata-test-files/input-SCVAUP.flac
x flac-1.4.3/test/flac-to-flac-metadata-test-files/input-SCVPAP.flac
x flac-1.4.3/test/flac-to-flac-metadata-test-files/input-SVAUP.flac
x flac-1.4.3/test/flac-to-flac-metadata-test-files/input-VA.flac
x flac-1.4.3/test/flac-to-flac-metadata-test-files/input0.cue
x flac-1.4.3/test/flac-to-flac-metadata-test-files/שלום.flac
x flac-1.4.3/test/flac-to-flac-metadata-test-files/🤔.flac
x flac-1.4.3/test/foreign-metadata-test-files/
x flac-1.4.3/test/foreign-metadata-test-files/24bit-WaveFmtPCM.wav
x flac-1.4.3/test/foreign-metadata-test-files/AIFF-C-sowt-compression-type-name.aifc
x flac-1.4.3/test/foreign-metadata-test-files/AIFF-C-sowt-tag.aifc
x flac-1.4.3/test/foreign-metadata-test-files/AIFF-ID3.aiff
...

I tested it one my home computer, that system locale's been set to US, and UI language's been English.
Surprisingly, the struct archive_string_conv *sc was not NULL at the first place.
The extraction finishes without error, although the Unicode file names get corrupted.
You can see what the gibberish file name looks like on the VSCode debugger image above.
The names are corrupted but thankfully those Unicode filenames, both in xiph-flac and ktx, are only in test resource folders.
Therefore they do not affect vcpkg build process.

Then I changed the computers system locale and UI language to Korean ones.
The result did not change, meaning changing system locale nor UI language alone do not trigger this issue.

I need to investigate further and find out the exact condition in which struct archive_string_conv *sc becomes NULL.
Once I completely figure out everything, I might make some PR or issue in the most appropriate project repo.
For the time being you may change system locale to en-US.

Or you may clone CMake source code, modify the specific function, build, and use the exe...

@junkoya
Copy link
Author

junkoya commented Jan 21, 2025

I tried to revert CMake from ver.3.31.4 to 3.30.5, and I temporally solved this issue.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
requires:repro The issue is not currently repro-able
Projects
None yet
Development

No branches or pull requests

3 participants