[GH-ISSUE #4464] [Feature Request] 链接动态库 #3528

Closed
opened 2026-05-05 14:16:01 -06:00 by gitea-mirror · 3 comments
Owner

Originally created by @Niculuse on GitHub (Oct 1, 2024).
Original GitHub issue: https://github.com/fatedier/frp/issues/4464

Describe the feature request

是否有办法在编译时链接系统动态库以减少程序体积,比如在openwrt的路由器上使用,链接openwrt的动态库,减少体积?

Describe alternatives you've considered

No response

Affected area

  • Docs
  • Installation
  • Performance and Scalability
  • Security
  • User Experience
  • Test and Release
  • Developer Infrastructure
  • Client Plugin
  • Server Plugin
  • Extensions
  • Others
Originally created by @Niculuse on GitHub (Oct 1, 2024). Original GitHub issue: https://github.com/fatedier/frp/issues/4464 ### Describe the feature request 是否有办法在编译时链接系统动态库以减少程序体积,比如在openwrt的路由器上使用,链接openwrt的动态库,减少体积? ### Describe alternatives you've considered _No response_ ### Affected area - [ ] Docs - [ ] Installation - [ ] Performance and Scalability - [ ] Security - [X] User Experience - [ ] Test and Release - [ ] Developer Infrastructure - [ ] Client Plugin - [ ] Server Plugin - [ ] Extensions - [X] Others
gitea-mirror 2026-05-05 14:16:01 -06:00
Author
Owner

@kkqy commented on GitHub (Oct 1, 2024):

frp是golang开发的,golang编译的程序体积大是“通病”了,网上有很多相关讨论,大意是Go团队认为对于现在的硬件资源而言,静态链接导致编译出来的文件体积过大并不是太大缺陷,静态链接能换来部署方便,开箱即用等好处,不会因为依赖的各种库版本不对而导致程序异常,他们认为用空间换便捷,是值得的。
而针对嵌入式环境,诞生了TinyGo项目,旨在生成体积更小的程序,遗憾的是TinyGo并没有完整实现Go的所有特性,所以就目前的情况,我不认为frp会为了缩小体积去针对TinyGo改造源码(我用TinyGo编译frp失败,frp使用的一部分包TinyGo没有实现),更不会去为了缩小体积去改造Go的编译器。看frp的说明,作者更新v2版本都是闲暇时间去做,也不大可能去做一个精简版的frp客户端。
现在路由器也可以内置TF卡、SSD或者外接USB存储,对于喜欢折腾的人来说,总会有办法搞得定的。
用UPX压缩一下,能减少不少体积,实测0.60.0的windows amd64的版本,压缩以后从14M变为只有4M左右了,但是我不确定某些环境对UPX压缩后的可执行程序支持好不好

<!-- gh-comment-id:2386389969 --> @kkqy commented on GitHub (Oct 1, 2024): frp是golang开发的,golang编译的程序体积大是“通病”了,网上有很多相关讨论,大意是Go团队认为对于现在的硬件资源而言,静态链接导致编译出来的文件体积过大并不是太大缺陷,静态链接能换来部署方便,开箱即用等好处,不会因为依赖的各种库版本不对而导致程序异常,他们认为用空间换便捷,是值得的。 而针对嵌入式环境,诞生了[TinyGo](https://github.com/tinygo-org/tinygo)项目,旨在生成体积更小的程序,遗憾的是TinyGo并没有完整实现Go的所有特性,所以就目前的情况,我不认为frp会为了缩小体积去针对TinyGo改造源码(我用TinyGo编译frp失败,frp使用的一部分包TinyGo没有实现),更不会去为了缩小体积去改造Go的编译器。看frp的说明,作者更新v2版本都是闲暇时间去做,也不大可能去做一个精简版的frp客户端。 现在路由器也可以内置TF卡、SSD或者外接USB存储,对于喜欢折腾的人来说,总会有办法搞得定的。 用UPX压缩一下,能减少不少体积,实测0.60.0的windows amd64的版本,压缩以后从14M变为只有4M左右了,但是我不确定某些环境对UPX压缩后的可执行程序支持好不好
Author
Owner

@superzjg commented on GitHub (Oct 2, 2024):

用楼上提到的 upx 压缩,openwrt 可以用,可以压缩到30~35%,运行时会先在 RAM 中解压,除了多占用 RAM,及解压时稍微慢一拍,没有其他影响,通过手动测试解压后与原来的md5相同。

<!-- gh-comment-id:2387306039 --> @superzjg commented on GitHub (Oct 2, 2024): 用楼上提到的 upx 压缩,openwrt 可以用,可以压缩到30~35%,运行时会先在 RAM 中解压,除了多占用 RAM,及解压时稍微慢一拍,没有其他影响,通过手动测试解压后与原来的md5相同。
Author
Owner

@github-actions[bot] commented on GitHub (Oct 23, 2024):

Issues go stale after 21d of inactivity. Stale issues rot after an additional 7d of inactivity and eventually close.

<!-- gh-comment-id:2430564613 --> @github-actions[bot] commented on GitHub (Oct 23, 2024): Issues go stale after 21d of inactivity. Stale issues rot after an additional 7d of inactivity and eventually close.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/frp#3528
No description provided.