已关闭
[Bug]: ios minimal deployment version not used by linker #541
Aleksey Mikhailov创建于  1月26日关闭于  8月25日
Aleksey Mikhailov
Aleksey Mikhailov
1月26日 创建

感谢对仓颉社区的支持与关注,欢迎反馈缺陷。

发生了什么问题?

I try to use cangjie binaries on iOS 12 simulator (it's x86_64 only). from source code of cangjie stdlib looks like stdlib compiled with ios 11 minimal version:
x86_64-apple-ios11-simulator

so i try to compile my code with x86_64-apple-ios12-simulator. but in result i got ios 17.5 minos:

cmd LC_BUILD_VERSION
  cmdsize 32
 platform 7
    minos 17.5
      sdk 26.1
   ntools 1
     tool 3
  version 15.0.4

期望行为是什么?

minos of binary should be 12 if we pass ios12 argument. this should work on every ios target - simulator and device, Apple Silicon and Intel.

如何复现该缺陷

test.cj:

package mytest

func helloWorld() {

}

try to compile:

cjc --experimental \
    --sysroot /Applications/Xcode.app//Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk \
    --target=x86_64-apple-ios12-simulator \
    --output-type=dylib \
    test.cj

check version:

otool -l libmytest.dylib | grep -E -A 12 "cmd (LC_VERSION_MIN_IPHONEOS|LC_BUILD_VERSION)"

will be:

cmd LC_BUILD_VERSION
  cmdsize 32
 platform 7
    minos 17.5
      sdk 26.1
   ntools 1
     tool 3
  version 15.0.4

其他补充信息

if we pass custom linking options - issue in our binary will be fixed, but issue still exist in stdlib, so we still can't use this binaries in ios 12 simulator (or any other ios lower then 17.5).

cjc --experimental \
    --sysroot /Applications/Xcode.app//Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk \
    --target=x86_64-apple-ios12-simulator \
    --output-type=dylib \
    --link-option -platform_version \
    --link-option ios-simulator \
    --link-option 12.0 \
    --link-option 17.5 \
    test.cj

in this case result will be:

cmd LC_VERSION_MIN_IPHONEOS
  cmdsize 16
  version 12.0
      sdk 17.5

but also:

ld64.lld: warning: /Users/amikhailov/Documents/projects/huawei/cangjie-sdk/ios-1.1.0-alpha.20260120020001/runtime/lib/ios_simulator_x86_64_cjnative/libcangjie-std-core.dylib has version 17.5.0, which is newer than target minimum of 12.0

we can check cangjie-std-core and see:

Load command 12
      cmd LC_BUILD_VERSION
  cmdsize 32
 platform 7
    minos 17.5
      sdk 17.5
   ntools 1
     tool 3
  version 15.0.4

cjc版本信息

Cangjie Compiler: 1.1.0-alpha.20260120020001 (cjnative)
Target: aarch64-apple-darwin

分支版本信息


[x] dev

[ ] main

[ ] release/1.0

[ ] release/OpenHarmony-release-6.0

likedislike
Aleksey MikhailovAleksey Mikhailov
1月26日 添加了label:bug
Aleksey Mikhailov
Aleksey Mikhailov
4月21日 评论:
likedislike
liujiajieliujiajie仓颉Committer
6月3日 关联了pull request:fix: 修复 iOS 链接器未使用 target 最低部署版本的问题
liujiajieliujiajie仓颉Committer
8月14日 关联了pull request:fix(build): 将 iOS 构建最低部署版本从 17.5 下调至 11(AST 库为 12)
liujiajieliujiajie仓颉Committer
8月14日 关联了pull request:fix(build): 将 iOS 构建最低部署版本从 17.5 下调至 11(syntax 库为 12)
liujiajieliujiajie仓颉Committer
8月15日 添加了label:1.2.0-beta.rc1
liujiajieliujiajie仓颉Committer
8月15日 添加了label:1.3.0-alpha.01
liujiajieliujiajie仓颉Committer
8月15日 删除了label:1.2.0-beta.rc1
Aleksey Mikhailov
Aleksey Mikhailov
8月25日 评论:

was fixed on 1.3.0-alpha.20260817010024

likedislike
Aleksey MikhailovAleksey Mikhailov
8月25日 关闭了 issue