Skip to content

Instantly share code, notes, and snippets.

@tiras-j
tiras-j / build_fix.patch
Created October 12, 2018 01:59
libz-sys patch for iOS? Adding _C99_SOURCE define
diff --git a/build.rs b/build.rs
index c3ac6c6..76ffe9d 100644
--- a/build.rs
+++ b/build.rs
@@ -104,6 +104,7 @@ fn build_zlib(cfg: &mut cc::Build, target: &str) {
cfg.define("STDC", None);
cfg.define("_LARGEFILE64_SOURCE", None);
cfg.define("_POSIX_SOURCE", None);
+ cfg.define("_C99_SOURCE", None);
cfg.flag("-fvisibility=hidden");
@tiras-j
tiras-j / snippet_stdio.h
Created October 12, 2018 01:54
libz-sys stdio.h snippet for aarch64-apple-ios sysroot
336 #if __DARWIN_C_LEVEL >= 200112L || defined(_C99_SOURCE) || defined(__cplusplus)
337 __BEGIN_DECLS
338 int snprintf(char * __restrict __str, size_t __size, const char * __restrict __format, ...) __printflike(3, 4);
339 int vfscanf(FILE * __restrict __stream, const char * __restrict __format, va_list) __scanflike(2, 0);
340 int vscanf(const char * __restrict __format, va_list) __scanflike(1, 0);
341 int vsnprintf(char * __restrict __str, size_t __size, const char * __restrict __format, va_list) __printflike(3, 0);
342 int vsscanf(const char * __restrict __str, const char * __restrict __format, va_list) __scanflike(2, 0);
343 __END_DECLS
344 #endif /* __DARWIN_C_LEVEL >= 200112L || defined(_C99_SOURCE) || defined(__cplusplus) */
@tiras-j
tiras-j / gist:ad7e54c50bee4beb3a01804259e4cd74
Created October 12, 2018 01:28
libz-sys simplified stdout compilation test
test.c:
#include <stdio.h>
int main(int argc, char *argv[]) {
char buf[128] = {0};
printf("TESTING TESTING TESTING\n");
snprintf(buf, 128, "%s", "TESTING TESTING TESTING\n");
printf("%s", buf);
}
@tiras-j
tiras-j / gist:e222e7310e87ab8c85d3faf160f452f6
Created October 12, 2018 01:18
libz-sys armv7s-apple-ios warnings
$ cargo build --release --target=armv7s-apple-ios
Compiling pkg-config v0.3.14
Compiling cc v1.0.25
Compiling libc v0.2.43
Compiling libz-sys v1.0.21 (file:///Users/jot/libz-sys)
warning: src/zlib/gzlib.c:214:15: warning: implicitly declaring library function 'snprintf' with type 'int (char *, unsigned long, const char *, ...)' [-Wimplicit-function-declaration]
warning: (void)snprintf(state->path, len + 1, "%s", (const char *)path);
warning: ^
warning: src/zlib/gzlib.c:214:15: note: include the header <stdio.h> or explicitly provide a declaration for 'snprintf'
warning: 1 warning generated.
@tiras-j
tiras-j / gist:a9f56a8cf333820c4dfd85f122d0355a
Created October 12, 2018 01:17
libz-sys armv7-apple-ios warnings
$ cargo build --release --target=armv7-apple-ios
Compiling pkg-config v0.3.14
Compiling cc v1.0.25
Compiling libc v0.2.43
Compiling libz-sys v1.0.21 (file:///Users/jot/libz-sys)
warning: src/zlib/gzlib.c:214:15: warning: implicitly declaring library function 'snprintf' with type 'int (char *, unsigned long, const char *, ...)' [-Wimplicit-function-declaration]
warning: (void)snprintf(state->path, len + 1, "%s", (const char *)path);
warning: ^
warning: src/zlib/gzlib.c:214:15: note: include the header <stdio.h> or explicitly provide a declaration for 'snprintf'
warning: 1 warning generated.
@tiras-j
tiras-j / gist:2bbc0dd1c57f7f54a657dcfa52244a81
Last active October 12, 2018 01:16
libz-sys aarch64-apple-ios compile failure
$ cargo build --release --target=aarch64-apple-ios
Compiling cc v1.0.25
Compiling pkg-config v0.3.14
Compiling libc v0.2.43
Compiling libz-sys v1.0.21 (file:///Users/jot/libz-sys)
error: failed to run custom build command for `libz-sys v1.0.21 (file:///Users/jot/libz-sys)`
process didn't exit successfully: `/Users/jot/libz-sys/target/release/build/libz-sys-830cfa7a396b97c0/build-script-build` (exit code: 101)
--- stdout
cargo:rerun-if-env-changed=LIBZ_SYS_STATIC
cargo:rerun-if-changed=build.rs