about summary refs log tree commit homepage
path: root/ext/mwrap/extconf.rb
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2023-01-08 05:03:26 +0000
committerEric Wong <e@80x24.org>2023-01-08 05:05:01 +0000
commitb5ab9be6686aa778a4cfd7622c598736b9c42321 (patch)
treea967297606a1f91f8359e287d5a85ad018e185e3 /ext/mwrap/extconf.rb
parent4356beb8237a92b3902b17f55cfe93d347b593d5 (diff)
parent2c25edb01139365f4754985c1e3494765dd1e5a7 (diff)
downloadmwrap-b5ab9be6686aa778a4cfd7622c598736b9c42321.tar.gz
This contains many changes from https://80x24.org/mwrap-perl.git
commit

* Built-in RCU-friendly version of dlmalloc, no more fragile dlsym(3m)
  resolution of malloc-family functions in the constructor

* Allocations are now backed by O_TMPFILE on $TMPDIR on modern Linux.
  Since mwrap increases memory usage greatly and I needed to use it
  on a system where I needed more VM space but lacked the ability
  to add swap.

* Configurable C backtrace level via MWRAP=bt:$DEPTH where $DEPTH
  is a non-negative integer.  Be careful about increasing it, even
  a depth of 3-4 can be orders-of-magnitude more expensive in
  time and space.  This can be changed dynamically at runtime via
  local HTTP (see below).

* Embedded per-process local-socket-only HTTP server obsoletes
  MwrapRack when combined with mwrap-rproxy from the Perl dist
  (set `MWRAP=socket_dir:/dir/of/sockets')
  See https://80x24.org/mwrap-perl/20221210015518.272576-4-e@80x24.org/
  for more info.

  It now supports downloading CSV (suitable for importing into sqlite 3.32.0+)

* License switched to GPL-3+ to be compatible with GNU binutils
  since we may take code from addr2line in the future.

* libxxhash supported if XXH3_64bits is available.
Diffstat (limited to 'ext/mwrap/extconf.rb')
-rw-r--r--ext/mwrap/extconf.rb31
1 files changed, 31 insertions, 0 deletions
diff --git a/ext/mwrap/extconf.rb b/ext/mwrap/extconf.rb
new file mode 100644
index 0000000..3336548
--- /dev/null
+++ b/ext/mwrap/extconf.rb
@@ -0,0 +1,31 @@
+# frozen_string_literal: true
+# Copyright (C) mwrap hackers <mwrap-public@80x24.org>
+# License: GPL-2.0+ <https://www.gnu.org/licenses/gpl-2.0.txt>
+require 'mkmf'
+
+have_func 'mempcpy'
+have_library 'urcu-cds' or abort 'userspace RCU not installed'
+have_header 'urcu/rculfhash.h' or abort 'rculfhash.h not found'
+have_library 'urcu-bp' or abort 'liburcu-bp not found'
+have_library 'dl'
+have_library 'c'
+have_library 'execinfo' # FreeBSD
+$defs << '-DHAVE_XXHASH' if have_header('xxhash.h')
+
+have_struct_member('struct sockaddr_un', 'sun_len', %w(sys/socket sys/un.h))
+
+if try_link(<<EOC)
+int main(void) { return __builtin_add_overflow_p(0,0,(int)1); }
+EOC
+  $defs << '-DHAVE_BUILTIN_ADD_OVERFLOW_P'
+end
+
+if try_link(<<EOC)
+int main(int a) { return __builtin_add_overflow(0,0,&a); }
+EOC
+  $defs << '-DHAVE_BUILTIN_ADD_OVERFLOW_P'
+else
+  abort 'missing __builtin_add_overflow'
+end
+
+create_makefile 'mwrap'