编译 OpenResty 的机器和运行 OpenResty 是同一台机器,机器比较老了,thinkpad t400, 2010年的
grep flag /proc/cpuinfo
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx lm constant_tsc arch_perfmon pebs bts nopl aperfmperf eagerfpu pni dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm sse4_1 xsave lahf_lm tpr_shadow vnmi flexpriority dtherm ida
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx lm constant_tsc arch_perfmon pebs bts nopl aperfmperf eagerfpu pni dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm sse4_1 xsave lahf_lm tpr_shadow vnmi flexpriority dtherm ida
看上去应该是不支持 sse4.2
运行configure,结果中有关sse的部分:
platform: linux (linux)
cp -rp bundle/ build
cd build
cd LuaJIT-2.1-20170405
INFO: found -msse4.2 in cc.
make TARGET_STRIP=@: CCDEBUG=-g XCFLAGS='-DLUAJIT_ENABLE_LUA52COMPAT -msse4.2' CC=cc PREFIX=/usr/local/openresty/luajit
。。。。。
==== Successfully built LuaJIT 2.1.0-beta2 ====
make install TARGET_STRIP=@: CCDEBUG=-g XCFLAGS='-DLUAJIT_ENABLE_LUA52COMPAT -msse4.2' CC=cc PREFIX=/usr/local/openresty/luajit DESTDIR=/home/will/openresty/openresty-1.11.2.3/build/luajit-root/
。。。。
是不是因为只是发现编译器支持sse4.2,没有考虑机器是否支持sse4.2,导致编译成功但运行错误
在 2017年5月6日星期六 UTC+8下午1:50:15,Zexuan Luo写道:
看上去像是由于在不支持 SSE4,2 上运行 SSE4.2 指令 _mm_crc32_u32 导致的问题。
但是有趣的是,我看源码里有
#if defined(__SSE4_2__) && defined(__x86_64) && defined(__GNUC__)
在不支持 SSE 4.2 的机器上不应该编译出来才对。
编译 OpenResty 的机器和运行 OpenResty 是否是同一台机器?
能否提供 grep flag /proc/cpuinfo 的输出结果?
在 2017年5月5日星期五 UTC+8上午11:37:53,ping yao写道:
完全参考
openresty.org/en/installation.html 里面的步骤
先安装工具
sudo apt-get install libreadline-dev libncurses5-dev libpcre3-dev \
libssl-dev perl make build-essential curl
./configure
configure最后输出:
checking for PCRE library ... found
checking for PCRE JIT support ... found
checking for OpenSSL library ... found
checking for zlib library ... found
creating objs/Makefile
Configuration summary
+ using system PCRE library
+ using system OpenSSL library
+ using system zlib library
nginx path prefix: "/usr/local/openresty/nginx"
nginx binary file: "/usr/local/openresty/nginx/sbin/nginx"
nginx modules path: "/usr/local/openresty/nginx/modules"
nginx configuration prefix: "/usr/local/openresty/nginx/conf"
nginx configuration file: "/usr/local/openresty/nginx/conf/nginx.conf"
nginx pid file: "/usr/local/openresty/nginx/logs/nginx.pid"
nginx error log file: "/usr/local/openresty/nginx/logs/error.log"
nginx http access log file: "/usr/local/openresty/nginx/logs/access.log"
nginx http client request body temporary files: "client_body_temp"
nginx http proxy temporary files: "proxy_temp"
nginx http fastcgi temporary files: "fastcgi_temp"
nginx http uwsgi temporary files: "uwsgi_temp"
nginx http scgi temporary files: "scgi_temp"
然后 make 没有报错
sudo make install 也成功
运行报错:
illegal instruction (core dumped)
:~/openresty/openresty-1.11.2.3$ gdb /usr/local/openresty/bin/openresty
GNU gdb (Ubuntu 7.11.1-0ubuntu1~16.04) 7.11.1
Copyright (C) 2016 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. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /usr/local/openresty/bin/openresty...done.
(gdb) r
Starting program: /usr/local/openresty/bin/openresty
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Program received signal SIGILL, Illegal instruction.
x64_init_random () at x64/src/lj_str_hash_x64.h:153
153 seed = _mm_crc32_u32(0, getpid());
(gdb) bt
#0 x64_init_random () at x64/src/lj_str_hash_x64.h:153
#1 x64_init_random_constructor () at x64/src/lj_str_hash_x64.h:185
#2 0x00007ffff7de74ea in call_init (l=<optimized out>, argc=argc@entry=1,
argv=argv@entry=0x7fffffffdc98, env=env@entry=0x7fffffffdca8)
at dl-init.c:72
#3 0x00007ffff7de75fb in call_init (env=0x7fffffffdca8, argv=0x7fffffffdc98,
argc=1, l=<optimized out>) at dl-init.c:30
#4 _dl_init (main_map=0x7ffff7ffe168, argc=1, argv=0x7fffffffdc98,
env=0x7fffffffdca8) at dl-init.c:120
#5 0x00007ffff7dd7cfa in _dl_start_user () from /lib64/ld-linux-x86-64.so.2
#6 0x0000000000000001 in ?? ()
#7 0x00007fffffffe078 in ?? ()
#8 0x0000000000000000 in ?? ()
(gdb)
不知道是什么原因,求救