当前位置: 首页 > news >正文

当make执行遇到 Arguments too long

1. 问题

Ubuntu20.04上make编译生成so的时候报错:

make[1]:execvp:/bin/sh:Arguments too long

对应makefile中的报错位置,仅仅是生成so的时候报错,伪代码如下

${build_tool} -shared -fpic -o "$@" ${OBJ_FILE} ${LDFLAGS}

然而如果不通过make执行,将后面的参数打印出来后,直接用交叉编译链执行是可以的,所以怀疑方向是在make

2. 分析:

(1)查看系统命令缓冲区大小,通过命令

xargs --show-limits 

执行结果:

limit

同时我也将这个库的合包段参数打出来看,确实很多 ,达到了 262 822(超过了系统 命令缓冲区的大小: 131072)

(2)进行一系列查询,到了ubuntu官方去查询,在make的changelog中又有找到类似问题的修复说明:


changelog

进一步在4.1的新版本4.1.9中的diff里找到有对应的修复4.1.9-diff,但4.2.1的版本里却没看到相关补丁内容,看起来是没有合到4.2.1中,那接下来尝试回退版本试试

3. 更新make版本实验验证

搭建虚拟机,匹配到Ubuntu 20.04,先用安装make V4.2.1版本进行编译复现问题,再降级到补丁的make版本进行编译观察是否解决
####(1)make V4.2.1版本安装: 装虚拟机后再 apt安装make即可
make-version
确认安装后Make版本一致,均为4.2.1,接下来进行make编译
arguments too long
编译结果现象一致

(2)补丁版本降级安装:

下载补丁版本:

https://mirrors.tscak.com/ubuntu/pool/main/m/make-dfsg/

下载对应的deb,我的安装包:

ubuntu-20.04.1-desktop-amd64.iso,uname -a

也看得到

root@ubuntu:~/make-4.1.9# uname -a Linux ubuntu 5.15.0-60-generic #66~20.04.1-Ubuntu SMP Wed Jan 25 09:41:30 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

所以下载:make_4.1-9.1ubuntu1_amd64.deb

下载到了直接编译好的deb,然后进行安装(中间遇到两次报错也记录了出来,也可以直接看最后一次正确安装)

root@ubuntu:~/make-4.1.9# sudo apt install make_4.1-9.1ubuntu1_amd64.deb  
Reading package lists... Done 
Building dependency tree        
Reading state information... Done 
E: Unable to locate package make_4.1-9.1ubuntu1_amd64.deb 

报错:

Unable to locate package make_4.1-9.1ubuntu1_amd64.deb

注意:(1)一定找对目录,到存在deb文件目录 (2)要安装的文件需要真的在这个文件夹下,然后以相对路径去执行,即加上 ./

root@ubuntu:~/make-4.1.9# sudo apt install -y ./make_4.1-9.1ubuntu1_amd64.deb
Reading package lists... Done 
Building dependency tree        
Reading state information... Done 
Note, selecting 'make' instead of './make_4.1-9.1ubuntu1_amd64.deb' 
Suggested packages:   
make-doc 
The following packages will be DOWNGRADED:   
make 
0 upgraded, 0 newly installed, 1 downgraded, 0 to remove and 238 not upgraded. 
E: Packages were downgraded and -y was used without --allow-downgrades.

报错:

Packages were downgraded and -y was used without --allow-downgrades.

正确安装:由于 包已经下在本地了,所以不需要-y, 去掉后重新装一次:

root@ubuntu:~/make-4.1.9# sudo apt install  ./make_4.1-9.1ubuntu1_amd64.deb    
Reading package lists... Done 
Building dependency tree        
Reading state information... Done 
Note, selecting 'make' instead of './make_4.1-9.1ubuntu1_amd64.deb' 
Suggested packages:   
make-doc 
The following packages will be DOWNGRADED:   
make 
0 upgraded, 0 newly installed, 1 downgraded, 0 to remove and 238 not upgraded. 
Need to get 0 B/154 kB of archives. 
After this operation, 12.3 kB disk space will be freed. 
Do you want to continue? [Y/n] y 
Get:1 /root/make-4.1.9/make_4.1-9.1ubuntu1_amd64.deb make amd64 4.1-9.1ubuntu1 [154 kB] 
dpkg: warning: downgrading make from 4.2.1-1.2 to 4.1-9.1ubuntu1 
(Reading database ... 238557 files and directories currently installed.) 
Preparing to unpack .../make_4.1-9.1ubuntu1_amd64.deb ... 
Unpacking make (4.1-9.1ubuntu1) over (4.2.1-1.2) ... 
Setting up make (4.1-9.1ubuntu1) ... Processing triggers for man-db (2.9.1-1) ... 
N: Download is performed unsandboxed as root as file '/root/make-4.1.9/make_4.1-9.1ubuntu1_amd64.deb' couldn't be accessed by user '_apt'. - pkgAcquire::Run (13: Permission denied) 
root@ubuntu:~/make-4.1.9# make --version  
GNU Make 4.1 
Built for x86_64-pc-linux-gnu 
Copyright (C) 1988-2014 Free Software Foundation, Inc. 
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> 
This is free software: you are free to change and redistribute it. 
There is NO WARRANTY, to the extent permitted by law. 
root@ubuntu:~/make-4.1.9# 

这里就能看到,原本是 4.2.1-1.2 降级到了 4.1-9。接下来再进行make,就能通过了

http://www.lryc.cn/news/6591.html

相关文章:

  • 《手把手教你》系列基础篇(七十三)-java+ selenium自动化测试-框架设计基础-TestNG实现启动不同浏览器(详解教程)
  • Maven基础
  • C++入门:初识类和对象
  • BERT在CNN上也能用?看看这篇ICLR Spotlight论文丨已开源
  • 【MFC】模拟采集系统——界面设计(17)
  • 锐捷(十五)mpls vxn跨域optionc场景
  • 2023备战金三银四,Python自动化软件测试面试宝典合集(七)
  • redis 主从复制
  • 如何用Redis实现延迟队列
  • 项目文件相关总结
  • ZooKeeper集群搭建步骤
  • 网际协议IP
  • Python 语言参考手册、教程、标准库
  • 数据库连接池 BoneCP、HikariCP 等
  • 博客系统 SSM 超强硬核良心推荐之第一弹 - 预备工作
  • [Web] 简单瀑布流布局实现
  • 多线程之死锁,哲学家就餐问题的实现
  • UTF-8编码
  • likeshop单商户SaaS版V1.8.2说明!
  • 算法训练营 day46 动态规划 最后一块石头的重量 II 目标和 一和零
  • nginx-host绕过实例复现
  • Java学习记录day9
  • ActiveReports.NET 17.0 Crack by Xacker
  • 【计算机网络】传输层TCP协议
  • Mysql5.7安装【Windows版】
  • 分布式一致性算法Raft原理图释
  • 网络安全-字典生成-crunch
  • 闪光桐人の实习日记
  • PostgreSQL 常见配置参数
  • JAVA 常用类型之String结构