Skip to content

Instantly share code, notes, and snippets.

Avatar
😸
Herding cats

Stephen Gutekanst slimsag

😸
Herding cats
View GitHub Profile
@slimsag
slimsag / ramblings.md
Last active Aug 8, 2022
Because cross-compiling binaries for Windows is easier than building natively
View ramblings.md

Because cross-compiling binaries for Windows is easier than building natively

I want Microsoft to do better, want Windows to be a decent development platform-and yet, I constantly see Microsoft playing the open source game: advertising how open-source and developer friendly they are - only to crush developers under the heel of the corporate behemoth's boot.

The people who work at Microsoft are amazing, kind, talented individuals. This is aimed at the company's leadership, who I feel has on many occassions crushed myself and other developers under. It's a plea for help.

The source of truth for the 'open source' C#, C++, Rust, and other Windows SDKs is proprietary

You probably haven't heard of it before, but if you've ever used win32 API bindings in C#, C++, Rust, or other languages, odds are they were generated from a repository called microsoft/win32metadata.

View gist:7693afaf9676bead77950446a66c9573
slimsag@hexopsblade15:~/Desktop/beyang/symf$ CGO_ENABLED=1 GOOS=darwin GOARCH=amd64 CC='zcc' CXX='zxx' go build -ldflags='-extldflags=-F/home/slimsag/Desktop/beyang/symf/sdk-macos-12.0/root/System/Library/Frameworks' -o test ./cmd/symf
# github.com/sourcegraph/symf/cmd/symf
warning: unsupported linker arg: -headerpad
warning: unsupported linker arg: 1144
warning: unsupported linker arg: -no_pie
warning: unsupported linker arg: -pagezero_size
warning: unsupported linker arg: 4000000
warning: unsupported linker arg: --compress-debug-sections
warning: unsupported linker arg: zlib-gnu
View args
C:\Users\slimsag\Desktop\zig\zig-out\bin\zig.exe build-lib C:\Users\slimsag\Desktop\mach2\gpu-dawn\src\dawn\dummy.zig -lc++ C:\Users\slimsag\Desktop\mach2\gpu-dawn\zig-cache\o\6bc980b450b4b05fab4cd621a1ba86cd\glfw.lib -lc -lgdi32 -cflags -g1 -std=c++17 -DDAWN_ENABLE_BACKEND_NULL -DDAWN_ENABLE_BACKEND_D3D12 -IC:\Users\slimsag\Desktop\mach2\gpu-dawn/libs/mach-glfw/upstream/glfw/include -IC:\Users\slimsag\Desktop\mach2\gpu-dawn/libs/dawn/out/Debug/gen/include -IC:\Users\slimsag\Desktop\mach2\gpu-dawn/libs/dawn/out/Debug/gen/src -IC:\Users\slimsag\Desktop\mach2\gpu-dawn/libs/dawn/include -IC:\Users\slimsag\Desktop\mach2\gpu-dawn/libs/dawn/src -D_DEBUG -D_MT -D_DLL -- C:\Users\slimsag\Desktop\mach2\gpu-dawn\src\dawn\dawn_native_mach.cpp -cflags -IC:\Users\slimsag\Desktop\mach2\gpu-dawn/libs/dawn/src -g1 -std=c++17 -- C:\Users\slimsag\Desktop\mach2\gpu-dawn\libs\dawn\src\dawn\common\Assert.cpp C:\Users\slimsag\Desktop\mach2\gpu-dawn\libs\dawn\src\dawn\common\DynamicLib.cpp C:\Users\slimsag\Desktop\mach2\gpu-dawn\li
View libcxx_incompatible
error(compilation): clang failed with stderr: zig: warning: argument unused during compilation: '-nostdinc++' [-Wunused-command-line-argument]
zig: warning: argument unused during compilation: '-nostdinc++' [-Wunused-command-line-argument]
In file included from C:\Users\slimsag\Desktop\zig\zig-out\lib\zig\libcxxabi\src/cxa_aux_runtime.cpp:14:
In file included from C:\Users\slimsag\Desktop\zig\zig-out\lib\zig\libcxx\include\typeinfo:75:
C:\Users\slimsag\Desktop\zig\zig-out\lib\zig\libc\include\any-windows-any\vcruntime_typeinfo.h:121:13: error: target of using declaration conflicts with declaration already in scope
C:\Users\slimsag\Desktop\zig\zig-out\lib\zig\libc\include\any-windows-any\vcruntime_typeinfo.h:69:7: note: target of using declaration
C:\Users\slimsag\Desktop\zig\zig-out\lib\zig\libcxxabi\include\cxxabi.h:30:27: note: conflicting declaration
error(compilation): clang failed with stderr: zig: warning: argument unused during compilation: '-nostdinc++' [-Wunused-command-line-argument]
zig: warning:
View widl_win32metadata_incompatible.md

WIDL compiler incompatibilities with Windows SDK

I attempted to compile the IDL files distributed in https://github.com/microsoft/win32metadata/tree/master/generation/WinSDK/RecompiledIdlHeaders using the latest (7.0.1-rc.1) version of the Wine IDL compiler, called WIDL. Unlike Microsoft's MIDL compiler which ships with Visual Studio, WIDL is open source.

More importantly, WIDL contains patches to generated header files that make e.g. COM calling conventions compatible with mingw-w64 and clang when targetting GNU ABI.

View gist:a55c0f6d715a8ab10e77b9b565e5ccc3
CREATE SCHEMA partman;
CREATE EXTENSION pg_partman SCHEMA partman;
CREATE ROLE partman WITH LOGIN;
GRANT ALL ON SCHEMA partman TO partman;
GRANT ALL ON ALL TABLES IN SCHEMA partman TO partman;
GRANT EXECUTE ON ALL FUNCTIONS IN SCHEMA partman TO partman;
GRANT EXECUTE ON ALL PROCEDURES IN SCHEMA partman TO partman; -- PG11+ only
GRANT ALL ON SCHEMA my_partition_schema TO partman;
GRANT TEMPORARY ON DATABASE sg to partman; -- allow creation of temp tables to move data out of default
View gist:826f2171c5d2296b7ecc3ef77ab84d1f
postgres=# SELECT sp.series_id, sp.time AS interval_time, SUM(value) as value, null as metadata
postgres-# FROM series_points sp JOIN repo_names rn ON sp.repo_name_id = rn.id
postgres-# WHERE series_id='s:7390958469D3357348D1873F0D7EE7D1130023CDE9AE614F6F945ACEBF4DD36D'
postgres-# GROUP BY sp.series_id, interval_time, sp.repo_name_id
postgres-# ORDER BY sp.series_id, interval_time, sp.repo_name_id DESC;
series_id | interval_time | value | metadata
--------------------------------------------------------------------+------------------------+-------+----------
s:7390958469D3357348D1873F0D7EE7D1130023CDE9AE614F6F945ACEBF4DD36D | 2020-09-01 00:00:00+00 | 0 |
s:7390958469D3357348D1873F0D7EE7D1130023CDE9AE614F6F945ACEBF4DD36D | 2020-09-01 00:00:00+00 | 0 |
s:7390958469D3357348D1873F0D7EE7D1130023CDE9AE614F6F945ACEBF4DD36D | 2020-09-01 00:00:00+00 | 0 |
View main.zig
const std = @import("std");
const builtin = @import("builtin");
const testing = std.testing;
const process = std.process;
const fs = std.fs;
const ChildProcess = std.ChildProcess;
var a: *std.mem.Allocator = undefined;
pub fn main() !void {
View gist:c28dd9b2aada8467ae1225b044043cfd
$ lldb -- /Users/slimsag/Desktop/hexops/zig/build/bin/zig build-exe /Users/slimsag/Desktop/hexops/zig/src/main.zig /Users/slimsag/Desktop/hexops/zig/build/zigcpp/libzigcpp.a /usr/local/opt/llvm/lib/libclangFrontendTool.a /usr/local/opt/llvm/lib/libclangCodeGen.a /usr/local/opt/llvm/lib/libclangFrontend.a /usr/local/opt/llvm/lib/libclangDriver.a /usr/local/opt/llvm/lib/libclangSerialization.a /usr/local/opt/llvm/lib/libclangSema.a /usr/local/opt/llvm/lib/libclangStaticAnalyzerFrontend.a /usr/local/opt/llvm/lib/libclangStaticAnalyzerCheckers.a /usr/local/opt/llvm/lib/libclangStaticAnalyzerCore.a /usr/local/opt/llvm/lib/libclangAnalysis.a /usr/local/opt/llvm/lib/libclangASTMatchers.a /usr/local/opt/llvm/lib/libclangAST.a /usr/local/opt/llvm/lib/libclangParse.a /usr/local/opt/llvm/lib/libclangSema.a /usr/local/opt/llvm/lib/libclangBasic.a /usr/local/opt/llvm/lib/libclangEdit.a /usr/local/opt/llvm/lib/libclangLex.a /usr/local/opt/llvm/lib/libclangARCMigrate.a /usr/local/opt/llvm/lib/libclangRewriteFrontend.a /usr/