1
0
mirror of https://github.com/skeeto/w64devkit.git synced 2025-04-19 17:42:15 +03:00

252 Commits

Author SHA1 Message Date
Christopher Wellons
3eae5e4919 gdb: Disable "Unsupported auto-load script" warning
Per comments in the GDB source, this warning is only supposed to be
shown once. Due to a bug it's shown every time, so just disable it
entirely. This affects Go targets, which is why it matters to me.
2023-12-31 21:37:51 -05:00
Christopher Wellons
fbf114d1e7 New command: vc++filt 2023-12-23 14:40:29 -05:00
Christopher Wellons
2a340634c3 Downgrade back to GDB 13.1 (#96)
i686-w64-mingw32 GDB 14.1 does not detect file changes. After rebuilds
it runs with stale debugging information and may put the target in an
invalid state. The user must either manually use the "file" command or
restart GDB in order to load changes. Mostly reverts f46b079.
2023-12-07 22:08:55 -05:00
Christopher Wellons
fa8724ee9a Upgrade to MPC 1.3.1 2023-12-07 12:41:38 -05:00
Christopher Wellons
4c04de4cb6 Upgrade to GNU Make 4.4.1 2023-12-07 12:41:02 -05:00
Christopher Wellons
709f676d35 Upgrade to busybox-w32 FRP-5236-g7dff7f376
* New shell options: nohiddenglob, nohidsysglob
* New applet/alias: lash ("ash -l")
* New sort option: -V
* Various bug fixes
2023-12-07 10:55:42 -05:00
Christopher Wellons
f46b079561 Upgrade to GDB 14.1 (#96)
In this release the --with-package options have broken further, and the
library detection scripts do not work at all. To workaround, toss these
options and manually place the include directory in CFLAGS, just as was
already necessary for LDFLAGS.
2023-12-07 10:01:45 -05:00
Christopher Wellons
8ec9a9abe6 Upgrade to MPFR 4.2.1 2023-12-07 10:01:45 -05:00
Christopher Wellons
d86184a25a Upgrade to GMP 6.3.0 2023-12-07 10:01:45 -05:00
Christopher Wellons
9926896660 Upgrade to Binutils 2.41 2023-12-07 10:01:44 -05:00
Christopher Wellons
0ea5fcf459 Bump to 1.21.0 v1.21.0 2023-12-05 12:16:51 -05:00
Christopher Wellons
46e4afd524 Upgrade from Debian Bullseye to Bookworm
Should have practically no effect beyond "zip" due to the bootstrap.
2023-09-12 14:11:59 -04:00
Christopher Wellons
addc923cb1 Upgrade to Mingw-w64 11.0.1
Cygwin fixes, no effect for w64devkit. The official release date was the
day following 11.0.0, on April 29th. However the project did not roll up
an actual, usable release until August 7th (today).
2023-09-06 19:21:57 -04:00
Christopher Wellons
35d858e43b Tidy alias.c, separate busybox-w32 aliases (#61)
The busybox-w32 alias binaries need not be unique. The command line
string contains all the necessary information, and busybox-w32 already
interprets that information properly. So just forward the command line
string to busybox.exe.

I also gave alias.c another tidying pass following my personal Windows
systems programming style. I'm sufficiently confident in this approach
that I feel it no longer requires apologetics. It speaks for itself. It
also now releases its "heap" before waiting on the target process.

While I'm at it, I also added a c89 command which is as "standard" as
the already-existing c99 command.
2023-09-04 19:52:31 -04:00
Christopher Wellons
2c4494a66d Always inline std::type_info::operator== (#86)
For ABI compatability, prior to -std=c++23 this method uses old inline
semantics. Because libstdc++ itself is not compiled as -std=c++23, it is
incompatible with -std=c++23 code using this method, even including some
libstdc++ headers like regex. However, it isn't obvious unless libstdc++
is statically linked, as it is in w64devkit. It's always been statically
linked, so ABI compatability across w64devkit releases is less important.
2023-09-04 19:51:37 -04:00
Christopher Wellons
568efdcd2c w64devkit.c: Improve legibility and maintenance
I've learned a lot since I wrote this two and half years ago. This was
one of my earliest serious attempts at building a CRT-free program, and
I had not yet learned the techniques to do so effectively. I lacked the
experience for dealing with certain common problems, and in some areas
approached it with the wrong mindset. For example, much of the original
program concerns tracking many little string lengths, which is finicky,
hard to follow, and difficult to modify. Better to operate in terms of
appending to buffers.

I also relied far too much on stack allocation, which has multiple
problems. First is friction with the toolchain. By default on Windows,
GCC inserts stack probes for frames larger than 4kiB in order to safely
commit more stack. Otherwise the program might skip the guard page. To
avoid this, I turned off probes and increased the committed stack size,
which requires multiple compiler/linker arguments. I'd like to avoid
that.

The second is that stack allocations have fixed, static sizes if you're
not using VLAs, which you're not if you're sane. So I need to figure out
and use the worst cast maximum sizes for everything. The stack has a
small, limited size, so I can't overestimate by too much either.

The third is that the stack remains committed until exit. There's no
giving it back before waiting on the long-lived shell process. It's
hardly anything, but I'd at least like the option.

All these problems are solved with region-based allocation. I get all
the nice stack semantics and lifetimes without any of the downsides. I
only really got the hang of arenas in the past couple years, which is
why I didn't use them in the original version. Now the entire program
probably uses under 1kiB of its stack.

I've also honed my style, in this case most notably in type names and
Win32 declarations. Along with no const, I find it much more readable
than the official names and style. As a bonus there's a nice, short
listing of all the required external functionality. This could be
plucked out as a .def file and used to build an import library, which
would eliminate the final dependency on Mingw-w64. Another major benefit
is faster build times. The new w64devkit.c cuts the build time by more
than 99%, merely by not including windows.h.

I've also learned other subtleties these past couple years:

1. GCC assumes the stack is 16-byte aligned, even on x86, but does not
guarantee 4-byte alignment, and such functions are usually called by
code not generated by GCC (e.g. called by Windows). This isn't only a
problem for CRT-free programs. It comes up most often with CreateThread,
and many GCC-compiled programs are subtly broken because of this. MSVC
and Clang do not have this issue.

2. GCC does not reliably generate correct code without -fno-builtin when
CRT-free, particularly for standard functions. Despite -fno-builtin, it
may generate calls to these functions, so sometimes you must provide
them. Clang also generates such calls despite being asked not to do so,
but it does not require -fno-builtin for correctness. You cannot even
ask MSVC not to call standard functions, but like Clang, it's careful
not to generate the wrong code for your own implementations. So always
use -fno-builtin with GCC when not linking a standard library.

3. While returning from the process entrypoint is technically valid and
generally works (in console applications), calling ExitProcess is more
robust and reliable. On Windows it's not uncommon for other processes to
meddle, including spawning uncooperative threads. These are bugs in the
other program, but they go unnoticed since virtually nothing actually
exits by returning from the entrypoint. It pays to play along.

4. In documentation, -nostartfiles is better than -nostdlib. It's
simpler and more fool-proof. When something's not working quite right,
it tends to quietly fill in the gaps. I still use -nostdlib in scripts
because it's stricter, and I can fix the problems that might arise.
2023-09-01 23:00:18 -04:00
Christopher Wellons
0a652a6c80 w64devkit.c: Set the console title to "w64devkit"
The default is just the path to the executable, which is neither useful
nor aesthetic. Thanks to @grable for the idea in #83.
2023-08-22 18:03:34 -04:00
Christopher Wellons
42d0a17ccc w64devkit.c: Redirect fatal() to ExitProcess (#83)
Should have been fixed in 6df612f, but it was overlooked.
2023-08-22 17:46:03 -04:00
Christopher Wellons
4f201b21f7 Upgrade to busybox-w32 FRP-5181-g5c1a3b00e
* New shell variable: BB_OVERRIDE_APPLETS
* Improved diff handling of CRLF
* Numerous upstream BusyBox fixes

https://frippery.org/busybox/release-notes/FRP-5181.html

The shell now supports "set -/+o noconsole" but this change forces the
window one way or another on start, interfering with the natural window
state. The included patch restores the old behavior of doing nothing on
"+o noconsole" (default) and actively hiding it on "-o noconsole".

This release also introduces wide API support through a UTF-8 manifest,
disabled by default. Unfortunately the manifest breaks compatibility
with anything before Windows 10 release 1903 and the binary will not
load, so it will never be enabled in w64devkit. This was all possible
already using either an adjacent manifest (busybox.exe.manifest) or by
amending the binary with it later (MSVC mt.exe), along with a manual
change of code page.

My initial plan was to enable CONFIG_FEATURE_UTF8_{INPUT,OUTPUT} to
improve UTF-8 handling, then users could manually install an adjacent
manifest to enable full Unicode support. Perhaps eventually that step
could be automated, disabling/enabling the manifest dynamically just
before running the executable. However, interactive UTF-8 editing is
still too broken to be worth using or enabling. The editing buffer is
easily corrupted, leading to confusing results.
2023-08-20 21:02:10 -04:00
Christopher Wellons
6df612f012 Replace CRT-free return with ExitProcess (#82)
ConEmu injects a thread (ConEmuCD.dll) and injects a DLL that starts
threads (ConEmuHk.dll). These threads may linger after the main thread
has returned, delaying the process exit and even interfering with the
exit status. As a work around, call ExitProcess instead of returning
from the main thread. This terminates extra threads so that the process
will no longer wait for their voluntarily exit.
2023-08-17 13:46:12 -04:00
Christopher Wellons
38129f8ace GDB: patch for "set confirm off" as the default
GDB's definition of "potentially dangerous" is far too broad. This
option creates substantial friction, discouraging debugger use, and
should be off by default.
2023-08-14 22:02:56 -04:00
Christopher Wellons
d5a1cce48b Bump to 1.20.0 v1.20.0 2023-08-01 10:40:08 -04:00
Christopher Wellons
586a1a10fb Adjust i686 patch to apply more accurately
The --with-arch=pentium4 keeps going under winpthreads because of the
matching context, which effectively disables it. One solution would be
to increase the context and deal with the extra conflicts. Instead
change the context so it doesn't match in the wrong place.
2023-08-01 10:40:08 -04:00
Christopher Wellons
1de55df78b Remove the "mini" variant
After the growth of various dependencies, the added weight of a C++
toolchain has become relatively small. I no longer feel it's worth
including as a separate variant.
2023-07-27 13:10:39 -04:00
Christopher Wellons
0814c8094b Update to GCC 13.2.0
https://gcc.gnu.org/gcc-13/changes.html
2023-07-27 09:02:31 -04:00
Christopher Wellons
2b0ae5a7f3 Add note to README.md about PowerShell (#69, #76)
Despite appearances, the ">" operator is actually a pipe to Out-File,
and GetFileType() returns FILE_TYPE_PIPE for that handle. It is not
seekable and does not behave like a file. By default it re-encodes its
input, which is virtually always destructive, unwanted, and surprising.
Regardless of the wording in its documentation, it is not possible to
connect process output to a file, and PowerShell does not support file
redirection.
2023-07-06 13:52:59 -04:00
Christopher Wellons
c17f5ca2b4 Use --with-default-msvcrt=msvcrt-os with Mingw-w64
The Mingw-w64 default may change to UCRT in the future, possibly soon,
but w64devkit will continue with the original msvcrt.dll for as long as
possible. It has far better compatibility with older systems, and UCRT
has limited availability prior to Windows 10.

The only benefits of linking UCRT that I know are better compatibility
when statically linking with UCRT-based toolchains, particularly MSVC,
and actually-working assertions (something Mingw-w64 could fix, as it
does printf, etc.). That's it! Mingw-w64 already fills in the missing
C99 bits. The Mingw-w64 documentation vaguely mentions a UTF-8 locale,
but it is either false or useless depending on the meaning. UCRT has all
the same narrow API limitations of MSVCRT — *the* biggest and thorniest
issue with Windows CRTs.

Trading away a ton of backwards compatibility just for better static
linking with MSVC sounds like a poor cost-benefit trade-off. In that
light, the choice of CRT seems obvious regardless of the Mingw-w64
default. My own view is that Windows CRTs have been poorly implemented
and are generally not worth using, so they should be avoided in the
first place, i.e. define {main,WinMain}CRTStartup, call Win32 directly,
and compile with -nostartfiles.

https://sourceforge.net/p/mingw-w64/mailman/message/37853546/
2023-06-12 23:05:40 -04:00
Christopher Wellons
2617b47433 Upgrade to busybox-w32 FRP-5007-g82accfc19
Many enhancements and fixes:
https://frippery.org/busybox/release-notes/FRP-5007.html
2023-05-28 11:58:41 -04:00
Christopher Wellons
7d8cb0eefc Update build script getopts string with "optimize"
Amends e76624e.
2023-05-06 12:07:03 -04:00
Christopher Wellons
c0bc4707ab Update README.md note about UBSan for GCC >= 13
The new option name is a lot nicer, so encourage its use! I don't know
if the old option will ever be removed.
2023-05-02 18:24:51 -04:00
Christopher Wellons
3824d4d5bb Bump to 1.19.0 v1.19.0 2023-05-02 15:03:31 -04:00
Christopher Wellons
e76624e29c Higher zip compression, disable default advzip
As of GDB 13.1, gdb.exe contains data triggering a bug in x64 Explorer
zip integration at last as far back as Windows 7. After recompressing
with advzip, gdb.exe extraction fails with 0x80004005 "Unspecified
error". This happens with both 32-bit and 64-bit gdb.exe regardless of
compiler flags. No other zip program has trouble with this file.

Until this is resolved, give up on advzip and tell zip to use -9. Also
renamed the build script option from -q (quick) to -O (optimize) and
disable its use by default.
2023-05-02 14:58:44 -04:00
Christopher Wellons
0423b551db GCC 13: Disable UTF-8 manifest for i686 (#58)
The manifest is incompatible with Windows XP and prevents GCC's
executables from starting on that platform.
2023-05-02 13:24:56 -04:00
GalaxySnail
0d6664471a Fix a Binutils 2.40 regression
In Binutils 2.40, there is a regression that ld fails with MSVC lib
files. Add a patch to fix it. Closes #59.

[1] https://github.com/msys2/MINGW-packages/issues/15469
[2] https://sourceware.org/bugzilla/show_bug.cgi?id=30079
2023-05-01 11:15:48 -04:00
Christopher Wellons
5875e0b326 Upgrade to Mingw-w64 11.0.0
Fixes to various headers. New Win32 APIs.

https://www.mingw-w64.org/changelog/#v1100-2023-04-28
2023-04-28 12:07:57 -04:00
Christopher Wellons
7256915e4b Update to GCC 13.1.0 2023-04-26 11:24:09 -04:00
Christopher Wellons
983d4718a2 Patch two Cppcheck bugs for upcoming GCC 13
Cppcheck does not compile with GCC 13 without these fixes, see:
https://gcc.gnu.org/gcc-13/porting_to.html
2023-04-26 11:23:45 -04:00
Braden Obrzut
5b2e053bd1 Add gdbserver binary for remote debugging 2023-04-25 15:26:58 -04:00
Christopher Wellons
122123c410 Upgrade to u-config 0.31.1 2023-04-10 19:38:31 -04:00
Christopher Wellons
7f6e0bac80 Upgrade to Binutils 2.40 2023-04-06 11:57:22 -04:00
Christopher Wellons
da042be364 In GDB prioritize wWinMain over wmain
Analagous to WinMain and main, but with -municode.
2023-03-13 11:43:18 -04:00
Christopher Wellons
74b79cc2f0 In GDB prioritize main over CRT-free entry points
Programs with main typically also have mainCRTStartup, but it's unlikely
that the user wants to break inside the CRT. If WinMain or wWinMain are
present, the user purposefully defined them, so prioritize those even
higher.
2023-03-13 10:52:43 -04:00
Christopher Wellons
3a981884ef Teach GDB about more Windows entry points
Windows programs have several conventional entry points depending on
various circumstances. Upstream GDB is only aware of "main" and the
"start" command behaves poorly or incorrectly otherwise.
2023-03-12 18:44:52 -04:00
Christopher Wellons
98a7d85129 Improve alias.c with a near rewrite
I've gotten a lot better at CRT-free since I first wrote this. I'm more
confident about this version, it produces better error messages, and it
compiles around 10x faster. The last point matters because w64devkit
currently compiles this program 181 times.
2023-02-26 21:59:28 -05:00
Christopher Wellons
d26683427a Remove Windows version define from GDB build
Originally a workaround (3316e7a), this bug was fixed upstream.
2023-02-22 13:53:43 -05:00
Christopher Wellons
3480a43a54 Upgrade to Universal Ctags 6.0.0
This is the first official versioned release of Universal Ctags, dated
December 2022. There were no prior tagged releases, let alone stable
source tarballs, so w64devkit piggy-backed off Debian's fork for the
needed stability.

This release has an official, stable source tarball, but it's broken and
practically useless. Further, the Git repository isn't tagged correctly,
having no annotated tags even for 6.0.0. Fortunately GitHub has recently
committed to generating stable source tarballs following backlash from
archive breakage in early February 2023. Because GitHub's source tarball
is more reliable than the official tarball, use it instead.
2023-02-22 13:48:49 -05:00
Christopher Wellons
bd00a3c9db Stop overriding default debug format in GCC
GDB 13.1 is the first release to fully support DWARF 5, and so this
override is no longer necessary.
2023-02-20 17:17:00 -05:00
Christopher Wellons
fdac8e333f Upgrade to GDB 13.1
For some reason this version introduces a "gdb.exe" wrapper script. As
far as I can tell it is unnecessary, so I'm ignoring it.
2023-02-20 17:09:03 -05:00
Christopher Wellons
b94d90de73 Introduce libiconv for GDB 12+
As of GDB 12.1, libiconv is a mandatory dependency on Windows. As with
Expat, this fact is undocumented. GDB builds successfully without but
that build is broken and practically useless. This dependency introduces
no new features nor makes GDB work better (i.e. GDB still cannot display
non-ASCII strings). It is necessary only to retain the capabilities
already present in GDB 11 an earlier.
2023-02-20 17:08:50 -05:00
Christopher Wellons
1c7435de9b Upgrade to busybox-w32 FRP-4882-g6e0a6b7e5
https://frippery.org/busybox/release-notes/FRP-4882.html
2023-02-15 20:27:44 -05:00