修复了macos arm64版本可能导致的lwjgl natives匹配错误#5990
Conversation
|
/gemini reivew |
There was a problem hiding this comment.
Code Review
This pull request enhances the native library patching mechanism to support ARM64 architectures on macOS and Windows, particularly for legacy LWJGL versions. It introduces a hasLegacyLwjglNatives check and a fallback replacement strategy using library classifiers. Additionally, several LWJGL 3.3.1 native mappings for macOS ARM64 were added to the configuration. Feedback was provided regarding redundant logging in the library replacement logic that could lead to duplicate output.
|
把 LWJGL 直接提升到这么高的版本真的能保持兼容性吗? |
cleaned repeated log when native patcher is triggered
本次修改并没有对当前版本的native patcher触发做过大修改,因为在arm64环境下,遇到没有系统架构标识的legacy classifier, 原逻辑会默认当做x86处理,所以这次修改仅为arm64环境下新增了legacy classifier的检测,且只对macos arm64做了特别处理。在classifier不是legacy的情况下, 1.19+版本仍会按照原逻辑执行。 |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 19b341eeba
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| for (Library lib : version.getLibraries()) { | ||
| if (!lib.appliesToCurrentEnvironment()) continue; | ||
| if (!"org.lwjgl".equals(lib.getGroupId())) continue; | ||
| if (!lib.isNative()) continue; |
There was a problem hiding this comment.
Treat classifier-only LWJGL entries as legacy natives
hasLegacyLwjglNatives filters with lib.isNative(), but Library.isNative() only returns true when natives or downloads.classifiers is present; a MultiMC/Forge-style library declared as "name": "org.lwjgl:...:natives-macos" (classifier in coordinate only) is treated as non-native and skipped here. In that case this method returns false, the early return at patchNative stays active for macOS/Windows ARM64 1.19+, and the legacy natives-macos mapping you added is never applied.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
通过multiMC程序打包的整合包, 在经过HMCL导入后,目前可见的legacy classifier仅遇到过downloads.classifiers的形式,未遇见过"name": "org.lwjgl:...:natives-macos"的形式,因此该特例认为可以暂时忽略
There was a problem hiding this comment.
示例json:
{ "name": "org.lwjgl:lwjgl-glfw:3.3.1", "downloads": { "artifact": { "url": "https://libraries.minecraft.net/org/lwjgl/lwjgl-glfw/3.3.1/lwjgl-glfw-3.3.1.jar", "sha1": "cbac1b8d30cb4795149c1ef540f912671a8616d0", "size": 128801 }, "classifiers": { "natives-linux": { "url": "https://libraries.minecraft.net/org/lwjgl/lwjgl-glfw/3.3.1/lwjgl-glfw-3.3.1-natives-linux.jar", "sha1": "81716978214ecbda15050ca394b06ef61501a49e", "size": 119817 }, "natives-macos": { "url": "https://libraries.minecraft.net/org/lwjgl/lwjgl-glfw/3.3.1/lwjgl-glfw-3.3.1-natives-macos.jar", "sha1": "9ec4ce1fc8c85fdef03ef4ff2aace6f5775fb280", "size": 131655 }, "natives-windows": { "url": "https://libraries.minecraft.net/org/lwjgl/lwjgl-glfw/3.3.1/lwjgl-glfw-3.3.1-natives-windows.jar", "sha1": "ed892f945cf7e79c8756796f32d00fa4ceaf573b", "size": 145512 } } }, "natives": { "linux": "natives-linux", "osx": "natives-macos", "windows": "natives-windows" } },
|
部分 MMC 整合包中用的 LWJGL 很老,这个 PR 不解决问题。 例如,https://github.com/search?q=repo%3AMultiMC%2Fmeta-multimc%20-nightly&type=code 这里能看到一些 Minecraft 1.6~1.18.2 版本正在使用 2.9.4-nightly-20150209 版本的 LWJGL。这些版本不能被正确替换本地库,但 HMCL 声称兼容这些版本。
|
你提到的老LWJGL替换问题确实存在,但这个PR的目标不是修复该问题。 不好意思,可能没有表达清楚,这个PR针对修复的是,1.19版本以上的macos arm64环境,导入multiMC打包的整合包时可能会遇到的LWGJL替换bug。 举个例子,导入multiMC打的整合包后,可能会使用legacy classifier, 因此这个PR主要是增加了1.19版本以上,对于arm64环境下 这类legacy classifier的额外检测,并将错误的x86源替换为arm64源。当运行环境是arm64, 又检测到了legacy classifier, 会主动去patch 成arm64版本 |


问题描述:
在macos arm64版本下,导入整合包时,某些Forge/MultiMC导出的manifests会使用LWJGL natives的已经legacy的classifier,如natives-macos。而由于HMCL会将1.19+版本的arm64自动跳过patch, 所以该classifier会继续保持,从而导致下载的LWJGL与系统版本不匹配并路径错误导致找不到。
修复方式
对于legacy的classifier做了检测,已经legacy的classifier会做patch