Skip to content

Instantly share code, notes, and snippets.

View NattyNarwhal's full-sized avatar
🐪
ML stands for metalanguage, not machine learning

Calvin Buckley NattyNarwhal

🐪
ML stands for metalanguage, not machine learning
View GitHub Profile
static int Fail(string msg, int code = 1)
{
Console.Error.WriteLine(msg);
return code;
}
static int Main(string[] args)
{
var outFile = args.Last();
args = args.Take(args.Length - 1).ToArray();
@NattyNarwhal
NattyNarwhal / diff.diff
Created June 12, 2018 02:48
Mono CoreFX PAL patch for feld
diff --git a/src/Native/Unix/System.Native/pal_io.c b/src/Native/Unix/System.Native/pal_io.c
index acb0097347..df9cd45318 100644
--- a/src/Native/Unix/System.Native/pal_io.c
+++ b/src/Native/Unix/System.Native/pal_io.c
@@ -5,6 +5,9 @@
#ifdef _AIX
// For getline (declare this before stdio)
#define _GETDELIM 1
+#elif __FreeBSD__
+// Similar to AIX, FreeBSD needs a definition too.
@NattyNarwhal
NattyNarwhal / getprocs64-enumeration-test.c
Created June 15, 2018 15:02
Enumerating processes on AIX with the getprocs64 function
#include <stdio.h>
#include <stdlib.h>
#include <procinfo.h>
#include <sys/types.h>
int main(void) {
struct procentry64 *procs;
pid_t pid;
int count, ret, pes, i;
aix$ ldd src/.libs/libgdiplus.so.0
src/.libs/libgdiplus.so.0 needs:
/opt/freeware/lib/libgcc_s.a(shr.o)
/opt/freeware/lib/libglib-2.0.a(libglib-2.0.so.0)
/usr/lib/libc.a(shr_64.o)
/opt/freeware/lib/libcairo.a(libcairo.so.2)
/opt/freeware/lib/libfontconfig.a(libfontconfig.so.1)
/opt/freeware/lib/libfreetype.a(libfreetype.so.6)
/usr/lib/libX11.a(shr_64.o)
/opt/freeware/lib/libjpeg.a(libjpeg.so.9)
@NattyNarwhal
NattyNarwhal / initial-work.diff
Created June 28, 2018 20:33
Initial work for Mono AOT on AIX
diff --git a/mono/mini/aot-compiler.c b/mono/mini/aot-compiler.c
index c5648e9..bab5949 100644
--- a/mono/mini/aot-compiler.c
+++ b/mono/mini/aot-compiler.c
@@ -948,6 +948,11 @@ emit_code_bytes (MonoAotCompile *acfg, const guint8* buf, int size)
#define EMIT_WIN32_CODEVIEW_INFO
#endif
+#ifdef _AIX
+#undef EMIT_DWARF_INFO
@NattyNarwhal
NattyNarwhal / gist:5e6dc925ef0056b08564f109ba9219f1
Created June 30, 2018 02:08
Profiling oksh build with gcc options
aix$ gmake
gcc -Q -ftime-report -DEMACS -DVI -w -D_ALL_SOURCE -c -o alloc.o alloc.c
strtold strtoimax select getdtablesize ainit afreeall alloc areallocarray aresize afree
Analyzing compilation unit
Performing interprocedural optimizations
<*free_lang_data> <visibility> <build_ssa_passes> <opt_local_passes> <free-inline-summary> <whole-program> <cdtor> <targetclone> <inline>Assembling functions:
<dispachercalls> strtold strtoimax select getdtablesize ainit afreeall alloc areallocarray aresize afree
Execution times (seconds)
phase setup : 0.00 ( 0%) usr 0.00 ( 0%) sys 0.01 ( 8%) wall 777 kB (28%) ggc
phase parsing : 0.03 (75%) usr 0.02 (100%) sys 0.09 (69%) wall 1573 kB (56%) ggc
bash-4.4$ truss -a -f -t kfork,execve,_exit /bin/sh ../../libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I../.. -I../.. -I../../mono -I../../mono/eglib -I../../mono/eglib -fvisibility=hidden -Wall -Wunused -Wmissing-prototypes -Wmissing-declarations -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Wpointer-arith -Wno-cast-qual -Wwrite-strings -Wno-switch -Wno-switch-enum -Wno-unused-value -Wno-attributes -Wno-format-zero-length -maix64 -DGC_AIX_THREADS -D_ALL_SOURCE -D_THREAD_SAFE -D_LARGE_FILES -D_REENTRANT -g -D__mono_ppc__ -D__mono_ppc64__ -Wall -Wunused -Wmissing-prototypes -Wmissing-declarations -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Wpointer-arith -Wno-cast-qual -Wwrite-strings -Wno-switch -Wno-switch-enum -Wno-unused-value -Wno-attributes -Wno-format-zero-length -g -O2 -std=gnu99 -fno-strict-aliasing -fwrapv -DMONO_DLL_EXPORT -Wno-unused-but-set-variable -g -mminimal-toc -Werror-implicit-function-declaration -MT libmonoutils_la-networking-fallback.lo -M
@NattyNarwhal
NattyNarwhal / README.md
Last active July 2, 2018 19:50
libarchive on AIX

Compiles cleanly. I tested against git master. Follow this:

bash build/autogen.sh # if you cloned from git instead of using a release tarball
CONFIG_SHELL=`which bash` AR=/usr/bin/ar NM=/usr/bin/nm LD=/usr/bin/ld ./configure
gmake # you can parallelize this with -j<NUMPROCS> - i recommend setting that to CPU cores

You will have to apply a patch included with this document; a real solution would be to fix it in configure.ac, but this is left as an exercise to the reader.

@NattyNarwhal
NattyNarwhal / stdint.h
Created July 15, 2018 01:12
ILE stdint
/* begin_generated_IBM_copyright_prolog */ /* This is an automatically generated copyright prolog. */ /* After initializing, DO NOT MODIFY OR MOVE */ /* ----------------------------------------------------------------- */ /* */ /* Product(s): */ /* 5722-SS1 */ /* 5761-SS1 */ /* 5770-SS1 */ /* */ /* (C)Copyright IBM Corp. 2005, 2013 */ /* */ /* All rights reserved.
*** The runtime 'mono' doesn't appear to be usable.
*** Trying the 'monolite-macos/1051700025' directory.
Stacktrace:
at <unknown> <0xffffffff>
at (wrapper managed-to-native) System.Text.EncodingHelper.InternalCodePage (int&) <0x000d8>
at System.Console..cctor () [0x0003c] in <b639830f9571483488f2a4773dd396f1>:0
at (wrapper runtime-invoke) object.runtime_invoke_void (object,intptr,intptr,intptr) [0x0001e] in <b639830f9571483488f2a4773dd396f1>:0
at <unknown> <0xffffffff>
at Mono.CSharp.Driver.Main (string[]) [0x00019] in <77f53e34a92f452696f1d782cddd3779>:0