Skip to content

Conversation

@Peefy
Copy link
Contributor

@Peefy Peefy commented Oct 31, 2022

1. Does this PR affect any open issues?(Y/N) and add issue references (e.g. "fix #123", "re #123".):

  • N
  • Y

re #53.

In order to better package KCLVM and reduce the probability of errors in the user's local kcl binary, the llvm library is statically packaged into the kcl binary to avoid using the user's local clang for assembling and linking. The goal is to solve the instability problem when KCL uses the user's clang/ld for code linking (mainly due to different versions of built-in cc on different OS).

Besides, after solving this problem, it is necessary to further move the python3 included in the KCLM from the KCLVM installation package to the outside to reduce the final KCLVM installation package size. cc @chai2010

Design

The previous compilation process is:
image

After the issue is completed, the KCLVM binary package only contains the following contents (Take the macos target as an example, and the size is ~80M-90M):

  • kclvm_cli # KCLVM Rust CLI (using kc run or kpm run later.)
  • libkclvm_native.dylib # KCLVM Runtime native Lib for native targets including macos, linux and windows target.
  • libkclvm_wasm32.dylib # KCLVM WASM32 lib for the WASM target.

Note:

  • Support targets: mac-x86, mac-arm, linux-x86 target.
  • TODO targets: windows, linux-arm WASM target.

2. What is the scope of this PR (e.g. component or file name):

  • kclvm_compiler crate.
  • kclvm_runner crate.

3. Provide a description of the PR(e.g. more details, effects, motivations or doc link):

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Other

4. Are there any breaking changes?(Y/N) and describe the breaking changes(e.g. more details, motivations or doc link):

  • N
  • Y

5. Are there test cases for these changes?(Y/N) select and add more details, references or doc links:

  • Unit test
  • Integration test
  • Benchmark (add benchmark stats below)
  • Manual test (add detailed scripts or steps below)
  • Other
  • Including all grammar and unit test suites.
  • Add macos github runners on macos10, macos11, macos12.

6. Release note

Please refer to Release Notes Language Style Guide to write a quality release note.

None

@Peefy Peefy added the release label Oct 31, 2022
@Peefy Peefy added this to the v0.4.4 Release milestone Oct 31, 2022
@Peefy Peefy self-assigned this Oct 31, 2022
@Peefy Peefy changed the title [WIP] refactor: compiling kcl code to object file instead of dylib and refactor: compiling kcl code to object file instead of dylib and LLVM ld library statically packaged in kclvm. [WIP] refactor: compiling kcl code to object file instead of dylib and LLVM ld library statically packaged in kclvm. Oct 31, 2022
@Peefy Peefy changed the title [WIP] refactor: compiling kcl code to object file instead of dylib and LLVM ld library statically packaged in kclvm. [WIP] refactor: compiling kcl code to object file instead of dylib and LLVM lld library statically packaged in kclvm. Oct 31, 2022
@coveralls
Copy link
Collaborator

coveralls commented Oct 31, 2022

Pull Request Test Coverage Report for Build 3407067403

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 89.712%

Totals Coverage Status
Change from base Build 3390800496: 0.0%
Covered Lines: 1369
Relevant Lines: 1526

💛 - Coveralls

@Peefy Peefy force-pushed the kclvm-static-link-llvm branch 10 times, most recently from 45001d6 to 0dab97a Compare November 2, 2022 14:56
@Peefy Peefy changed the title [WIP] refactor: compiling kcl code to object file instead of dylib and LLVM lld library statically packaged in kclvm. refactor: compiling kcl code to object file instead of dylib and LLVM lld library statically packaged in kclvm. Nov 4, 2022
@Peefy Peefy changed the title refactor: compiling kcl code to object file instead of dylib and LLVM lld library statically packaged in kclvm. [WIP] refactor: compiling kcl code to object file instead of dylib and LLVM lld library statically packaged in kclvm. Nov 4, 2022
@Peefy Peefy changed the title [WIP] refactor: compiling kcl code to object file instead of dylib and LLVM lld library statically packaged in kclvm. [WIP] refactor: compiling kcl code to object file instead of dylib and packaging LLVM lld library statically into kclvm binary. Nov 4, 2022
@Peefy Peefy force-pushed the kclvm-static-link-llvm branch from 046a10a to ed055db Compare November 4, 2022 11:10
@Peefy Peefy changed the title [WIP] refactor: compiling kcl code to object file instead of dylib and packaging LLVM lld library statically into kclvm binary. refactor: compiling kcl code to object file instead of dylib and packaging LLVM lld library statically into kclvm binary. Nov 4, 2022
@Peefy Peefy force-pushed the kclvm-static-link-llvm branch from ed055db to 646c5d7 Compare November 4, 2022 12:11
@Peefy Peefy force-pushed the kclvm-static-link-llvm branch from 646c5d7 to 7d26129 Compare November 5, 2022 12:25
@ldxdl
Copy link
Contributor

ldxdl commented Nov 5, 2022

lgtm

ldxdl
ldxdl previously approved these changes Nov 5, 2022
Copy link
Contributor

@zong-zhe zong-zhe left a comment

Choose a reason for hiding this comment

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

LGTM

@ldxdl ldxdl merged commit 0f45eeb into kcl-lang:main Nov 7, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Nov 7, 2022
@Peefy Peefy deleted the kclvm-static-link-llvm branch January 16, 2023 13:13
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants