RPM 构建在同一个客户操作系统上,在另一台主机上发生段错误(Asterisk)

RPM 构建在同一个客户操作系统上,在另一台主机上发生段错误(Asterisk)

我使用在 OSX 上运行的构建 VM(MacBook,使用 Parallels)为 Centos 7 构建了 Asterisk 13 的 RPM。目的是在我们的 QA 和生产系统上使用此 RPM。

但是,在其中一个 QA 服务器上安装 RPM 后,Asterisk 在启动时立即出现段错误,无法运行。QA 服务器是另一个 Centos 7 VM,运行在 Intel CPU 上,Centos 主机使用 KVM(Qemu)。

我的 RPM 规范文件是:

%define _prefix /usr/local
%define _ver    13.4.0
%define _unpackaged_files_terminate_build 0
%define debug_package %{nil}

Name:          asterisk
Version:       %{_ver}
Release:       1
Summary:       Asterisk
Vendor:        Asterisk
Packager:      Amir Abiri <???>
Source:        http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-%{_ver}.tar.gz
URL:           http://www.asterisk.org/
Group:         Applications/Multimedia
BuildRequires: ncurses-devel
BuildRequires: libuuid-devel
BuildRequires: jansson-devel
BuildRequires: sqlite-devel

%description
-

%prep
%setup

%build
./configure
make

%install
make install DESTDIR=$RPM_BUILD_ROOT
mkdir -p "$RPM_BUILD_ROOT/usr/lib/systemd/system"
cp %{_topdir}/PATCHES/asterisk/asterisk.service "$RPM_BUILD_ROOT/usr/lib/systemd/system"

%post
/sbin/ldconfig 2>/dev/null
systemctl enable asterisk

%postun
/sbin/ldconfig 2>/dev/null
systemctl disable asterisk

%files
%defattr (-,root,root)
/usr/sbin/*
/usr/lib/asterisk/*
/usr/lib/libasteriskssl.so*
%exclude /usr/include/asterisk*
/usr/lib/systemd/system/asterisk.service
/var/lib/asterisk/*
/usr/share/man/*

GCC 版本是:

4.8.3 20140911 (Red Hat 4.8.3-9)

构建虚拟机(OSX 主机)的 cpuinfo 是:

processor   : 0
vendor_id   : GenuineIntel
cpu family  : 6
model       : 70
model name  : Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz
stepping    : 1
cpu MHz     : 2194.000
cache size  : 6144 KB
physical id : 0
siblings    : 2
core id     : 0
cpu cores   : 2
apicid      : 0
initial apicid  : 0
fpu     : yes
fpu_exception   : yes
cpuid level : 13
wp      : yes
flags       : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts mmx fxsr sse sse2 ss ht syscall nx rdtscp lm constant_tsc nopl xtopology nonstop_tsc eagerfpu pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt aes xsave avx f16c rdrand hypervisor lahf_lm ida arat xsaveopt pln pts dtherm fsgsbase bmi1 avx2 smep bmi2 invpcid
bogomips    : 4388.00
clflush size    : 64
cache_alignment : 64
address sizes   : 36 bits physical, 48 bits virtual
power management:

QA 服务器 VM 的 cpuinfo 是:

processor   : 0
vendor_id   : GenuineIntel
cpu family  : 6
model       : 13
model name  : QEMU Virtual CPU version 1.5.3
stepping    : 3
microcode   : 0x1
cpu MHz     : 3092.836
cache size  : 4096 KB
physical id : 0
siblings    : 1
core id     : 0
cpu cores   : 1
apicid      : 0
initial apicid  : 0
fpu     : yes
fpu_exception   : yes
cpuid level : 4
wp      : yes
flags       : fpu de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pse36 clflush mmx fxsr sse sse2 syscall nx lm rep_good nopl pni cx16 hypervisor lahf_lm abm
bogomips    : 6185.67
clflush size    : 64
cache_alignment : 64
address sizes   : 39 bits physical, 48 bits virtual
power management:

如果我通过 strace 运行 sagfaulting asterisk,则 strace 输出的最后半屏是:

clone(child_stack=0x7f5d487c3f70, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID, parent_tidptr=0x7f5d487c49d0, tls=0x7f5d487c4700, child_tidptr=0x7f5d487c49d0) = 4583
mmap(NULL, 507904, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_STACK, -1, 0) = 0x7f5d486cd000
mprotect(0x7f5d486cd000, 4096, PROT_NONE) = 0
clone(child_stack=0x7f5d48747f70, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID, parent_tidptr=0x7f5d487489d0, tls=0x7f5d48748700, child_tidptr=0x7f5d487489d0) = 4584
open("/dev/urandom", O_RDONLY|O_CLOEXEC) = 6
fcntl(6, F_GETFD)                       = 0x1 (flags FD_CLOEXEC)
fcntl(6, F_SETFD, FD_CLOEXEC)           = 0
getuid()                                = 0
getppid()                               = 4569
read(6, "\242Dm\252\343n\333\22\264\177,\355m\1w\300", 16) = 16
close(6)                                = 0
gettid()                                = 4572
stat("/etc/asterisk/codecs.conf", 0x7fffc4362f20) = -1 ENOENT (No such file or directory)
mmap(NULL, 507904, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_STACK, -1, 0) = 0x7f5d48651000
mprotect(0x7f5d48651000, 4096, PROT_NONE) = 0
clone(child_stack=0x7f5d486cbf70, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID, parent_tidptr=0x7f5d486cc9d0, tls=0x7f5d486cc700, child_tidptr=0x7f5d486cc9d0) = 4585
mmap(NULL, 507904, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_STACK, -1, 0) = 0x7f5d485d5000
mprotect(0x7f5d485d5000, 4096, PROT_NONE) = 0
clone(child_stack=0x7f5d4864ff70, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID, parent_tidptr=0x7f5d486509d0, tls=0x7f5d48650700, child_tidptr=0x7f5d486509d0) = 4586
brk(0)                                  = 0x1993000
brk(0x19b4000)                          = 0x19b4000
open("/dev/urandom", O_RDONLY|O_CLOEXEC) = 6
fcntl(6, F_GETFD)                       = 0x1 (flags FD_CLOEXEC)
fcntl(6, F_SETFD, FD_CLOEXEC)           = 0
getuid()                                = 0
getppid()                               = 4569
read(6, "\251\357\241U\357\267\34G\314@\272\256r\341\210r", 16) = 16
close(6)                                = 0
gettid()                                = 4572
stat("/etc/asterisk/modules.conf", {st_mode=S_IFREG|0644, st_size=2768, ...}) = 0
open("/etc/asterisk/modules.conf", O_RDONLY) = 6
fstat(6, {st_mode=S_IFREG|0644, st_size=2768, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f5d4b6ab000
read(6, "[modules]\nautoload = no\n\n; This "..., 4096) = 2768
read(6, "", 4096)                       = 0
close(6)                                = 0
munmap(0x7f5d4b6ab000, 4096)            = 0
stat("/etc/asterisk/features.conf", 0x7fffc4362ea0) = -1 ENOENT (No such file or directory)
--- SIGILL {si_signo=SIGILL, si_code=ILL_ILLOPN, si_addr=0x5d5a57} ---
+++ killed by SIGILL (core dumped) +++

答案1

如果您想在一台机器上构建并在另一台机器上运行,则需要禁用 BUILD_NATIVE 选项。

在您的 %build 部分尝试:

./configure
make menuselect.makeopts
menuselect/menuselect --disable BUILD_NATIVE menuselect.makeopts
make

相关内容