aboutsummaryrefslogtreecommitdiff
path: root/doc/software.md
blob: 728e84b2f8a0077baaaaf701be5bc37cc80d1757 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# Software notes

This document lists some software known to build successfully, and any
special procedures necessary.

## sbase

Builds without issue with musl. On glibc, there are some errors due to
the declaration of `strsep` conflicting with the system declaration in
usage of `restrict` (see [#50]).

[#50]: https://todo.sr.ht/~mcf/cc-issues/50

## mcpp

Builds without issue.

## binutils

QBE must be built with `NPred` (in `all.h`) at least 297, or patched to
use dynamic arrays for phi predecessors ([f6a7d135]).

On glibc systems, you must make sure to include `crtbegin.o` and
`crtend.o` from gcc at the end of `startfiles` and beginning of `endfiles`
respectively.

On musl systems, you must define `long double` to match `double` (as
below) to avoid errors in unused `static inline` functions in musl's
`math.h`. Note: this is a hack and won't be ABI-incompatible with musl;
things will break if any functions with `long double` get called.

```diff
-struct type typeldouble = FLTTYPE(TYPELDOUBLE, 16, NULL);  // XXX: not supported by qbe
+struct type typeldouble = FLTTYPE(TYPELDOUBLE, 8, &f64);
```

Requires several patches available here:
https://github.com/michaelforney/binutils-gdb/

- Fix function pointer subtraction in `bfd/doc/chew.c` (applied upstream).
- Skip unsupported `LDFLAGS`, only tested to work against `CXX` by
  configure, but applied to `CC` as well.
- Disable `long double` support in `_bfd_doprnt`.
- Alter some ifdefs to avoid statement expressions and VLAs.
- Implement `pex_unix_exec_child` with `posix_spawn` instead of `vfork`
  and subtle `volatile` usage.
- Make `regcomp` and `regexec` match the header declaration in usage of
  `restrict`.
- Don't declare `vasprintf` unless it was checked for and not
  found. Several subdirectories in binutils include `libiberty.h`,
  but don't use `vasprintf`, causing conflicting declarations with libc
  in usage of `restrict`.
- Make sure `config.h` is included in `arlex.c` so that the appropriate
  feature-test macros get defined to expose `strdup`.

Configure with

	./configure CC=/path/to/cc CFLAGS_FOR_BUILD=-D_GNU_SOURCE \
		--disable-intl --disable-gdb --disable-plugins --disable-readline

[f6a7d135]: https://git.sr.ht/~mcf/qbe/commit/f6a7d135d54f5281547f20cc4f72a5e85862157c

## zstd

Requires disabling CPU identification inline assembly and deprecation
warnings.

```diff
diff --git a/lib/common/cpu.h b/lib/common/cpu.h
index 5f0923fc..10dd7d7f 100644
--- a/lib/common/cpu.h
+++ b/lib/common/cpu.h
@@ -52,6 +52,7 @@ MEM_STATIC ZSTD_cpuid_t ZSTD_cpuid(void) {
             f7c = (U32)reg[2];
         }
     }
+#elif 1
 #elif defined(__i386__) && defined(__PIC__) && !defined(__clang__) && defined(__GNUC__)
     /* The following block like the normal cpuid branch below, but gcc
      * reserves ebx for use of its pic register so we must specially
```

Build with

	make CC=/path/to/cc CFLAGS='-DZDICT_DISABLE_DEPRECATE_WARNINGS -DZBUFF_DISABLE_DEPRECATE_WARNINGS' zstd

Some tests fail, which still need to be investigated.

## st

Requires a few changes to avoid wide string literals and including
`math.h` on musl targets. On glibc, the declaration of `sigpause` in
`signal.h` with an asm label is not yet supported ([#60]), but since
this is not used, you can define it away by adding `-D '__asm__(x)='`
to your `CFLAGS`.

```diff
diff --git a/config.def.h b/config.def.h
index 482901e..bd963ae 100644
--- a/config.def.h
+++ b/config.def.h
@@ -32,7 +32,7 @@ static float chscale = 1.0;
  *
  * More advanced example: L" `'\"()[]{}"
  */
-wchar_t *worddelimiters = L" ";
+wchar_t *worddelimiters = (wchar_t[]){' ', 0};
 
 /* selection timeouts (in milliseconds) */
 static unsigned int doubleclicktimeout = 300;
diff --git a/x.c b/x.c
index 5828a3b..6e006cc 100644
--- a/x.c
+++ b/x.c
@@ -1,6 +1,5 @@
 /* See LICENSE for license details. */
 #include <errno.h>
-#include <math.h>
 #include <limits.h>
 #include <locale.h>
 #include <signal.h>
@@ -15,6 +14,8 @@
 #include <X11/Xft/Xft.h>
 #include <X11/XKBlib.h>
 
+float ceilf(float);
+
 static char *argv0;
 #include "arg.h"
 #include "st.h"
```