Jay Krell [Wed, 5 Dec 2018 00:18:02 +0000 (16:18 -0800)]
Fix more warnings. (#11853)
This isn't correct for Win64 but that should be ok.
It is correct for all other platforms.
And beware icall-decl.h + Boehm producing:
w32file-unix.c:4905:16: error: implicit declaration of function 'GC_dlopen' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
libc_handle = dlopen ("/usr/lib/libc.dylib", 0);
^
or, if you fix that, unreferenced symbol _GC_dlopen.
* [cxx] [boehm] favor void* over char* interface for easier use from C++.
This tracks, barely.
See https://github.com/ivmai/bdwgc/blob/ae3d724f3645af119e1b2c2cefbb71c97d467546/mark.c#L1337
Mainline and Unity Boehm are valid C++, which is not the case here.
Jay Krell [Tue, 1 May 2018 15:46:02 +0000 (08:46 -0700)]
Have automake copy instead of symlink, for more git checkout sharability (#8534)
* Make autogen.sh output accurate -- print actual commands run.
* Have automake copy instead of symlink.
- This sounds analogous to libtool --copy that we do.
- It enables sharing a source tree more broadly.
For real example, Cygwin symlinks are not portable to Windows Subsystem For Linux, and probably vice versa.
For real example, Homebrew symlinks are not portable to Linux in Docker.
Downside I notice is that ls -l is less informative as to what is from git vs. a symlink to outside.
git clean -xxddff works just as well either way.
Hypothetical downside is that updating automake/autoconf doesn't upgrade the copies.
This has never mattered to me, but it might matter. It might be viewed as an advantage.
thfrwn [Thu, 29 Mar 2018 15:25:23 +0000 (08:25 -0700)]
add some OpenBSD patches (#7699)
add some OpenBSD patches
Hi,
A few trivial additions of OpenBSD to ifdefs, plus the change of the abort signal to SIGUSR1 which fixes the SIGABRT problem (other compilation problems remain). SIGTTIN is broadcast to the process group which leads to the SIGABRT (at least on OpenBSD).
* [libgc] Export GC_start_blocking () and GC_end_blocking ().
* [libgc] Allow GC_start_blocking ()/GC_end_blocking () to be called unbalanced.
This makes things a bit easier in Mono.
* [libgc] Implement GC_start_blocking ()/GC_end_blocking () for Windows.
* [utils/event] Export the MonoOSEvent APIs for use in the profiler.
* [runtime] Implement thread info flags and get rid of tools threads.
The concept of a tools thread was originally a good solution to the problem of
some internal threads needing to be exempt from stop-the-world. Since they were
introduced, however, we've added more code in the profiler's internal threads
which require certain properties that don't hold true for tools threads. In
particular, we call into some APIs in the metadata layer that, while not
needing the managed heap, do need a domain to be set under certain conditions
(see #6188).
To avoid further complicating the semantics of tools thread by trying to set a
domain for them in a way that doesn't break things horribly, we'll instead do
away with the concept entirely. We already had mono_gc_set_skip_thread () to
flag a thread as being exempt from stop-the-world, which we used in thread pool
threads. This means we already have the infrastructure that is necessary for a
thread to be fully attached to the runtime as a managed thread while still
being exempt from stop-the-world.
So, we do the following:
1. Introduce a set of flags that can be set on a MonoThreadInfo at arbitrary
points (although not in async context). These can indicate that the thread
doesn't want to participate in stop-the-world, doesn't want to receive
sampling signals, etc.
2. Change the thread iteration macros to allow skipping threads with specific
flags set and use this where appropriate (e.g. SGen stop-the-world code).
3. Get rid of mono_gc_set_skip_thread () and make runtime code use the new
mono_thread_info_set_flags () instead.
4. Switch all internal profiler threads to using mono_thread_attach () and
mono_thread_detach (). Use mono_thread_info_set_flags () to disable
stop-the-world and sampling signals for these threads immediately after they
start.
With these changes, internal profiler threads are now fully attached threads
and can call any APIs in the runtime as long as they don't touch the managed
heap.
* [libgc] Add a note about how GC_start_blocking ()/GC_end_blocking () differ from upstream.
Robert Nagy [Mon, 8 Jan 2018 09:25:19 +0000 (10:25 +0100)]
openbsd related patches (#6358)
* include netinet/in.h for in_addr_t
* there is no need for an openbsd specific implementation anymore
so you use the generic pthread one
* signal.h is required for sigaltstack
* add missing mono/utils/mono-threads.h include
* there is no malloc.h on OpenBSD either
* sys/socket.h is required for struct sockaddr
* add support for btls on openbsd and default to with_tls=pthread as there is only emultls support which is not enough for mono
* there is no need for pthread_attr_init/destroy anymore
* add -Wl,-zwxneeded to LDFLAGS on OpenBSD
W^X is strictly enforced by default on OpenBSD;
a program can only violate it if it is located on a filesystem mounted
with the wxallowed mount(8) option and has been linked with the
above flag
Calvin [Wed, 6 Dec 2017 20:43:20 +0000 (16:43 -0400)]
Compile on amd64 Haiku (#4473)
* Compile on amd64 Haiku
Use sigcontext (somewhat like win32, or x86) on Haiku amd64.
On amd64, Haiku doesn't have issues with marshalling 64-bit values,
but it currently does have issues with SGen either causing a stall
or a core dump. As such, while it can compile the stdlib (further
than x86 got), it's still a work in progress.
* Use set_real_time_clock for sys-time.c on Haiku
* Get mono-boehm compiling on Haiku again
It still doesn't work. Initialization will call GC_mark_from, which
will cause a segmentation fault as it decrements pointers. (Mono
will enter an infinite loop in mono_get_hazardous_pointer as a result.)
For now, mono-sgen will continue to be used by default.
* Remove the mark/reclaim events as they've been broken for a long time and
aren't particularly useful.
* Reorder the enum member declarations to the order they actually arrive in.
Vlad Brezae [Thu, 10 Nov 2016 22:24:51 +0000 (00:24 +0200)]
Refactor and unify tls access
The purpose of this commit is to unify tls access across all platforms. We had tls information spread out throughout the entire code which was guarded with many defines/capabilities which made very hard to follow what was going on. Also this made switching between pthread and __thread very unstable since there were a lot of dependencies between different pieces of the tls infrastructure. Also it was not very clear what happens if one of the tls pieces failed.
Now we are moving all the tls variables to a single module that provides getters/setters and initialization API. Runtime code now knows that we can always access a tls variable (from managed code, we just do a nowrapper icall into the same global geters/setters). Even though we used to these type of calls all around before, it is worth mentioning that runtime should account for a thread to be in this type of unregistered code without m2n wrapper and no register jinfo.
On average this makes common tls intensive methods (m2n wrappers and managed allocator) 20% slower, with potential for more regression if we use tls getters/setters recklessly. As a consequence we will re-enable the most important pieces of fast tls code in the future.
On musl __GLIBC__ is not defined, so the conditional logic will
not produce correct result. Add a specific case to handle when
__GLIBC__ is not defined.
James Laird-Wah [Sun, 7 Feb 2016 23:19:53 +0000 (10:19 +1100)]
libgc: use __builtin_frame_address in GC_approx_sp
With GCC 5.x, the compiler optimises away the dummy load used to
estimate the stack pointer address in GC_approx_sp; it returns
zero. This leads to segfaults when embedding Mono.
Instead, use __builtin_frame_address, which GCC's libgc uses for
the same purpose.
Neil Mayhew [Fri, 12 Jun 2015 20:03:21 +0000 (14:03 -0600)]
Check for libtoolize rather than libtool
Current Debian packaging puts libtool in its own package (libtool-bin)
leaving only libtoolize in the main package. The mono build process
uses libtoolize not libtool, so during autogen check for libtoolize
not libtool.
Ivan Maidanski [Mon, 16 Nov 2015 07:09:55 +0000 (10:09 +0300)]
Put *_freelists into thread_local_freelists (as in BDWGC v7)
Mono create_allocator accesses libgc private *_freelists directly.
These fields have been grouped together into struct
thread_local_freelists in BDWGC v7.
This commit does code refactoring to match the structure of external
GC regarding *_freelists.
* Move GRANULARITY, NFREELISTS (used by *_freelists) out of
GC_Thread_Rep.
* Move ptrfree_freelists, normal_freelists, gcj_freelists from
GC_Thread_Rep to struct thread_local_freelists.
* Add tlfs field (of type struct thread_local_freelists) to
GC_Thread_Rep.
* Update pthread_support.c and boehm-gc.c code accordingly.
* Replace global variable with a setter:
- GC_notify_event -> GC_set_on_collection_event() (acquires GC lock)
* Foreign threads registration:
- add GC_allow_register_threads() (no-op for GC v6, called by
mono_gc_base_init)
- add GC_SUCCESS, GC_DUPLICATE, GC_NO_MEMORY, GC_UNIMPLEMENTED macros
- add struct GC_stack_base
- replace GC_thread_register_foreign(void*) with
GC_register_my_thread(struct GC_stack_base)
- define GC_register_my_thread also for Solaris and Win32
- GC_register_my_thread returns GC_DUPLICATE if already registered
* Toggle-ref callback declaration change:
- add GC_ToggleRefStatus (enum type)
- callback returns GC_ToggleRefStatus instead of int
* Toggle-ref addition status checked:
- GC_toggleref_add return type changed from void to int
- GC_toggleref_add returns GC_SUCCESS or GC_NO_MEMORY
- static ensure_toggleref_capacity() returns FALSE if GC MALLOC failed
- call g_error() if GC_toggleref_add failed
* Conditional public function declaration:
- wrap GC_DllMain declaration into ifdef GC_INSIDE_DLL
- define GC_INSIDE_DLL prior to include gc.h
Jo Shields [Thu, 31 Jul 2014 09:26:34 +0000 (10:26 +0100)]
Support for GNU/kFreeBSD.
GNU/kFreeBSD is an experimental OS provided by the Debian project, consisting
of a FreeBSD kernel and GNU userland/libc. For a small number of cases, this
offers advantages over a more common GNU/Linux combination, such as fast
in-kernel support for ZFS storage.
This patch changes various ifdefs, either using __FreeBSD_kernel__ where a
trait from the kernel is what matters, or __GLIBC__ where a trait from the
C library matters.
This patch set has been carried downstream, in one form or another, since
1.2.3.1-1.
Add ARM version detection to configure and use the resulting macros.
This defines ARM_VERSION_{5,6,7}. Several of these can be
defined at once. For example ARM_VERSION_5 and ARM_VERSION_6
will both be defined if the target is an ARM v6 CPU.
Previously, we defined HAVE_ARMV6 based on running a program.
This obviously didn't work for cross-compilation. This new
approach does, and detects more cases (v5, v6, v7) than the
previous check (v6).
Neale Ferguson [Thu, 9 May 2013 19:42:58 +0000 (15:42 -0400)]
gcconfig.h - Add weak attribute to avoid __data_start undefined messages on dlopen mini-s390x.c - Add profiling support to prolog/epilog instrumentation
Elijah Taylor [Thu, 31 Jan 2013 20:04:20 +0000 (12:04 -0800)]
NaCl runtime fixes
- fix compile/runtime issues caused by upstream changes
- add NaCl glibc support
- various changes to support running tests in NaCl glibc
from 'make check'
Elijah Taylor [Thu, 31 Jan 2013 20:48:49 +0000 (12:48 -0800)]
NaCl GC improvements
- inline managed code implementation
(add x86 test mem imm8 codegen macro for this as well)
- clean up libgc NaCl code
- centralize mono_nacl_gc into mini.c
Josh DuBois [Tue, 12 Feb 2013 17:55:35 +0000 (11:55 -0600)]
Include <stdint.h> to allow cross-compilation from OS X.
Cross-compiling mono on an OS X host for a Windows target using
mingw-w64 fails because of undefined __int64 types in a couple of places.
Including <stdint.h> fixes this and allows the OS X host to cross-compile
a Windows mono.
It probably sounds like an obscure use-case, but the wine-mono
project does just this, so ability to cross-compile for Windows on OS X
is crucial to being able to build wine-mono on a Mac.
Rodrigo Kumpera [Wed, 16 Jan 2013 19:58:56 +0000 (14:58 -0500)]
Add long links support to Boehm.
* gc.h: Added parts of boehm 7.3a long link API.
* finalize.c (GC_finalize): Implemented long link support by adapting
code from boehm 7.3a.
The idea is to have two table of links, one for regular and another
for the long links. Regular links are processed before finalization
and the long ones right after. The bulk of the changes are abstracting
the disappearing link hashtable into a data structure so we can have
two of them.
Boehm code came from github.com/ivmai/bdwgc.git. Authors of the
relevant changes are Zach Saw and Ivan Maidanski.
Zoltan Varga [Wed, 3 Oct 2012 08:26:37 +0000 (10:26 +0200)]
Use AM_CPPFLAGS instead of INCLUDES in Makefile.am files, as the later is no longer supported, see http://lists.gnu.org/archive/html/automake/2012-08/msg00087.html.
Zoltan Varga [Sat, 3 Mar 2012 16:14:02 +0000 (17:14 +0100)]
Revert "Get rid of the <foo>-static libraries, libtool doesn't know that they need to be compiled only in static mode, so each source file was compiled up to 8 times. Pass -static in the _LDFLAGS for the mono executables instead."
Zoltan Varga [Wed, 8 Feb 2012 20:04:20 +0000 (21:04 +0100)]
Get rid of the <foo>-static libraries, libtool doesn't know that they need to be compiled only in static mode, so each source file was compiled up to 8 times. Pass -static in the _LDFLAGS for the mono executables instead.
Geoff Norton [Wed, 3 Aug 2011 01:45:49 +0000 (21:45 -0400)]
Darwin/AMD64 can have 64-bit thread id's, so we need to ensure we cast properly to make sure the modulus has a valid result. Additionally add support for x86_THREAD_STATE64.
[boehm] Avoid a ENOMEM when allocating across an unallocated page
A very rare allocation pattern could cause the boehm free list to call
the GC_unmap_gap function, which actually calls down into munmap().
Darwins virtual memory manager will return a KERN_INVALID_ADDRESS
which is translated into a ENOMEM, if mprotect attempts to change
the protection of a range which includes an unallocated page.
We address this by just mmap() back to ANON, instead of actually
unallocating the page.