Skip to content

Conversation

@Artoria2e5
Copy link
Contributor

@Artoria2e5 Artoria2e5 commented Oct 11, 2025

  • Add myfnmatch.c/h for simple wildcard matching. Unix systems have fnmatch() but Windows doesn't, so we provide a version from musl.
    • If I was any greedier I would import gnulib and use regex from there. But that would be a lot more lines!
  • Use fnmatch() to:
    • Match GPU models, which is what you get on not-Linux. Should improve detection on Windows and macOS.
    • Match gfx-targets, which is what you get on Linux. Should cover more AMD GPUs. Also added matching for CDNA, which are chonkier versions of GCN5 (1:1 FP64 for all CDNA, 1:1 INT32 MUL since CDNA2)
  • Cover RDNA4 and RDNA3.5 as using RDNA3 features. Should help with mfakto 0.16-beta.3 and no support for RDNA4 ? #43 but definitely test before closing.
  • Edit the ini comments to match how we actually use the architectures. Especially APU, since no new APU is put in that bucket.

Compiles on mingw-w64 (MSYS2 "Mingw64") with the following caveat:

  • No LTO enabled. Using LTO causes a symbol resolution error between C++ mangled and C non-mangled symbols on fnmatch when linking. This is most likely a toolchain bug, since fnmatch is built under C and referenced with extern C.

* Add myfnmatch.c/h for simple wildcard matching. Unix systems have
  fnmatch() but Windows doesn't, so we provide a version from musl.
* Use fnmatch() to:
  * Match GPU models, which is what you get on not-Linux. Should improve
    detection on Windows and macOS.
  * Match gfx-targets, which is what you get on Linux. Should cover more
    AMD GPUs.
    Also added matching for CDNA, which are chonkier versions of GCN5.
* Cover RDNA4 and RDNA3.5 as using RDNA3 features. Should help with primesearch#43
  but definitely test before closing.
@ixfd64 ixfd64 requested review from N-Storm, brubsby and proski October 11, 2025 17:47
@ixfd64 ixfd64 added the enhancement New feature or request label Oct 11, 2025
@ixfd64
Copy link
Member

ixfd64 commented Oct 11, 2025

Your code was only compiling on Windows. I've fixed the macOS and Linux build errors.

…ompilers and just causes them to print multiple warnings
@ixfd64 ixfd64 force-pushed the patch-1 branch 4 times, most recently from 08cabca to 9d9c0e6 Compare October 13, 2025 21:29
@ixfd64 ixfd64 requested a review from tdulcet October 14, 2025 17:06
@ixfd64
Copy link
Member

ixfd64 commented Oct 14, 2025

I don't see any issues with your changes. However, I'd like others to take a look at it as well if possible.

In the meantime, I've improved the code formatting and INI file comments. Hope you don't mind. :-)

@Artoria2e5
Copy link
Contributor Author

These are all good changes! I am thinking about removing the mention of Rtl... whatever the glob thing on Windows is though, because with the use of brackets in the patterns it just won't work. I initially wanted to use simpler patterns (or at last some sort of two-stage matching where the complex character-sets are just replaced by ?), but that turned out unnecessary with how small a proper fnmatch is.

@ixfd64
Copy link
Member

ixfd64 commented Oct 16, 2025

I think the ideal solution would be to install external dependencies via a package manager. However, that's not really an option in this case because musl doesn't seem to be in the vcpkg repo.

@N-Storm
Copy link
Member

N-Storm commented Oct 17, 2025

Wouldn't PathMatchSpecExA() work as a replacement for fnmatch() on Windows?

@Artoria2e5
Copy link
Contributor Author

The better replacement is the Rtl stuff in ntdll. The path one has, well, path-specific idiosyncrasies especially with 8.3 that we don't need. But even "better" isn't good enough as I've decided to be greedy and reach for the [] part of POSIX glob patterns.

Copy link
Member

@N-Storm N-Storm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don’t see any obvious issues. I didn’t check the complex code in myfnmatch.c in detail, but it matches the upstream version from musl, taking into account the declared changes that remove unnecessary functionality for some flags.

What does concern me, though, is that the build with LTO on MinGW doesn’t work. It’s probably worth examining this further, but I don’t have enough spare time right now to look into it. So I’ll approve the PR for now, but this should be revisited later.

@ixfd64 ixfd64 merged commit d06464f into primesearch:master Oct 20, 2025
5 checks passed
@Artoria2e5
Copy link
Contributor Author

WAIT A SECOND fnmatch matches the whole string, so if anything is to be matched a bunch of * is needed woah great job me now I have a lot to explain

@ixfd64 ixfd64 linked an issue Nov 11, 2025 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mfakto 0.16-beta.3 and no support for RDNA4 ?

3 participants