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

Fix mimalloc debug build #6263

Draft
wants to merge 1 commit into
base: dev
Choose a base branch
from
Draft

Conversation

WSSDude
Copy link
Contributor

@WSSDude WSSDude commented Feb 1, 2025

Unsure if this is proper fix as I am unsure if the folder may be different on different platform or not, but this fixes compilation on the latest Windows 11 system using latest Visual Studio 2022 and xmake 2.9.7 for debug builds.

@WSSDude
Copy link
Contributor Author

WSSDude commented Feb 1, 2025

For some extra context - when trying to compile while requiring the package in debug, it is trying to copy pdb from root of build directory and it is unable to find it there. The pdb is located in <build>/pdb/Debug in this case and not the <build> folder, failing the install step.

@WSSDude WSSDude marked this pull request as draft February 1, 2025 05:50
@WSSDude
Copy link
Contributor Author

WSSDude commented Feb 1, 2025

Hm, this still doesn't function in the end I realized, unsure how to fix this, is a bit annoying... Can only use the lib in release mode which is not the best for debugging purposes.

@WSSDude WSSDude force-pushed the mimalloc-fix-debug branch from ec35e28 to 310a31e Compare February 1, 2025 06:01
@WSSDude
Copy link
Contributor Author

WSSDude commented Feb 1, 2025

Ok, latest change works when I try with the following in my xmake file

add_requires("mimalloc")

And compile in debug mode.

It fails though when I also add tiltedcore 0.2.7 into the add_requires in the above snippet, with regular mimalloc require running fine and one included by tiltedcore failing. So there seems to be something else broken when the package is included from another and modified in the above way. The PDB seems to not get generated at all, unsure how to fix this exactly.

local dir = package:installdir(package:config("shared") and "bin" or "lib")
os.cp(path.join(package:buildir(), "mimalloc-debug.pdb"), dir)
os.cp(path.join(package:buildir(), "pdb", "Debug", pdb), dir)
end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code can be removed, fixed by xmake-io/xmake#5566

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can confirm this as a whole can be removed and works fine for the regular add_requires, still have the same exact issue with dependent package which includes it.

@star-hengxing
Copy link
Contributor

add_requires("mimalloc[shared]")

pdb generate by msbuild:

build_xxx/pdb/<build type>/

pdb generate by ninja:

build_xxx/pdb/

Enable by policy package.cmake_generator.ninja

https://github.com/xmake-io/xmake/blob/78371cb084abfe3e80e928adae4e55a0df98f34b/xmake/modules/package/tools/cmake.lua#L1383-L1389

if package:is_plat("windows") and os.isdir("pdb") then
    if package:config("shared") or not package:is_library() then
        os.trycp("pdb/**.pdb", package:installdir("bin"))
    else
        os.trycp("pdb/**.pdb", package:installdir("lib"))
    end
end

@WSSDude
Copy link
Contributor Author

WSSDude commented Feb 1, 2025

Can confirm the line can be removed but it still does not fix the issue.

mimalloc included by tiltedcore package seems to be an issue somehow, but that package is not doing anything special.

checking for debug.x64 ...
checking for Microsoft Visual Studio (x64) version ... 2022
checking for Microsoft C/C++ Compiler (x64) version ... 19.40.33813
  => install mimalloc v2.1.7 .. ok
  => install mimalloc#1 v2.1.7 .. failed

cannot copy file build_5604f22e\pdb\Debug\mimalloc-static-debug.pdb, file not found!
if you want to get more verbose errors, please see:
  -> C:\Users\andre\AppData\Local\.xmake\cache\packages\2502\m\mimalloc_1\v2.1.7\installdir.failed\logs\install.txt
error: install failed!

There is nothing special in the install.txt, only that single error. Looking into build_5604f22e, there exists folder pdb/Debug but it is empty. For the one that runs OK, there is a normal PDB file present in that folder.

PDB simply does not get generated for the case where mimalloc is included from another package, at least not from tiltedcore which literally only has add_requires("mimalloc") looking at it.

Trying to use add_requires("mimalloc[shared]") to bypass this (at least I understood it should be some bypass), doesnt work still (above log is from the run with it included)

@WSSDude
Copy link
Contributor Author

WSSDude commented Feb 1, 2025

Also for the record, I tried to add set_policy("package.cmake_generator.ninja", true) into the package as well, commit what I tested with now that produced the log mentioned in previous comment.

@WSSDude WSSDude force-pushed the mimalloc-fix-debug branch from 310a31e to 8bde75e Compare February 1, 2025 14:55
@WSSDude
Copy link
Contributor Author

WSSDude commented Feb 1, 2025

Maybe this is some xmake error then from what I gather overall? Or am I missing something still?

@star-hengxing
Copy link
Contributor

Can confirm the line can be removed but it still does not fix the issue.

mimalloc included by tiltedcore package seems to be an issue somehow, but that package is not doing anything special.

checking for debug.x64 ...
checking for Microsoft Visual Studio (x64) version ... 2022
checking for Microsoft C/C++ Compiler (x64) version ... 19.40.33813
  => install mimalloc v2.1.7 .. ok
  => install mimalloc#1 v2.1.7 .. failed

cannot copy file build_5604f22e\pdb\Debug\mimalloc-static-debug.pdb, file not found!
if you want to get more verbose errors, please see:
  -> C:\Users\andre\AppData\Local\.xmake\cache\packages\2502\m\mimalloc_1\v2.1.7\installdir.failed\logs\install.txt
error: install failed!

There is nothing special in the install.txt, only that single error. Looking into build_5604f22e, there exists folder pdb/Debug but it is empty. For the one that runs OK, there is a normal PDB file present in that folder.

PDB simply does not get generated for the case where mimalloc is included from another package, at least not from tiltedcore which literally only has add_requires("mimalloc") looking at it.

Trying to use add_requires("mimalloc[shared]") to bypass this (at least I understood it should be some bypass), doesnt work still (above log is from the run with it included)

@waruqi Any idea?

@star-hengxing
Copy link
Contributor

Try add_requireconfs("mimalloc", {configs = {rltgenrandom = true}}) to avoid building multiple version (configs) mimalloc

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

Successfully merging this pull request may close these issues.

2 participants