Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Drop Phobos dependency for compiler tests #16587

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

kinke
Copy link
Contributor

@kinke kinke commented Jun 15, 2024

The goal here is to render make dmd-test totally independent from Phobos, only depending on druntime in the same repo here.

@dlang-bot
Copy link
Contributor

Thanks for your pull request and interest in making D better, @kinke! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please verify that your PR follows this checklist:

  • My PR is fully covered with tests (you can see the coverage diff by visiting the details link of the codecov check)
  • My PR is as minimal as possible (smaller, focused PRs are easier to review than big ones)
  • I have provided a detailed rationale explaining my changes
  • New or modified functions have Ddoc comments (with Params: and Returns:)

Please see CONTRIBUTING.md for more information.


If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment.

Bugzilla references

Your PR doesn't reference any Bugzilla issue.

If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.

Testing this PR locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub run digger -- build "master + dmd#16587"

@kinke kinke force-pushed the compiler_tests_without_phobos branch from 212a600 to 6bda4c1 Compare June 15, 2024 10:57
@kinke
Copy link
Contributor Author

kinke commented Jun 15, 2024

Currently just useful to get a CI-generated list of problematic tests that would need to be adapted (incl. handling the ^^ operator). E.g., from https://github.com/dlang/dmd/actions/runs/9528085481/job/26265410251?pr=16587:

FAILED targets:
- runnable/xtest46_gc.d
- runnable/argufilem.d
- runnable/xtest46.d
- runnable/arrayop.d
- runnable/paranoia.d
- runnable/link11069b.d
- runnable/testassign.d
- runnable/testabi.d
- runnable/stress.d
- runnable/test5943.d
- runnable/test13117.d
- runnable/ctorpowtests.d
- runnable/test12197.d
- runnable/wc3.d
- runnable/wc.d
- runnable/test13117b.d
- runnable/testaa2.d
- runnable/wc2.d
- runnable/builtin.d
- compilable/compile1.d
- compilable/issue17167.sh
- compilable/test15019.d
- compilable/json2.d
- compilable/paranoia_ctfe.d
- compilable/test5227.d
- compilable/ctfe_math.d
- compilable/b19294.d
- fail_compilation/ice7782.d
- fail_compilation/diag10327.d
- fail_compilation/test22361.d
- fail_compilation/fail21091b.d
- fail_compilation/b3841.d
- fail_compilation/fail21091a.d
- fail_compilation/fail18938.d
- fail_compilation/fail22366.d

The dshell tests have been hacked out for now, as their prebuilt-part (using the fresh DMD, not the host compiler) unfortunately depends on Phobos, and that early build failure hid the actual test results.

@kinke
Copy link
Contributor Author

kinke commented Jun 15, 2024

It's not just the pow operator, but std.math is special in general - the compiler recognizes std.math function calls during CTFE and handles them in https://github.com/dlang/dmd/blob/master/compiler/src/dmd/builtin.d via hardcoded identifiers. There are multiple compiler tests for these CTFE builtins.

So maybe std.math should be migrated to core.math in druntime.

@kinke kinke force-pushed the compiler_tests_without_phobos branch from 737e2e6 to 48d9332 Compare June 15, 2024 12:31
@kinke kinke force-pushed the compiler_tests_without_phobos branch from 48d9332 to 8318103 Compare June 15, 2024 13:12
@rikkimax
Copy link
Contributor

I looked at the power function in std.math, it's a pretty involved affair to move that out, if I remember right it needs exp.

It's not just std.math that has to be moved either, it's multiple modules.

It doesn't work in -betterC because not all of it is templated, it's horribly coupled to having a binary.

https://issues.dlang.org/show_bug.cgi?id=23538

@kinke
Copy link
Contributor Author

kinke commented Jun 15, 2024

I looked at the power function in std.math, it's a pretty involved affair to move that out, if I remember right it needs exp.

It's not just std.math that has to be moved either, it's multiple modules.

The entire std.math package of course. IIRC, it's pretty self-contained, shouldn't depend on lots of other Phobos stuff.

It doesn't work in -betterC because not all of it is templated, it's horribly coupled to having a binary.

Please keep the discussion on this topic, that's entirely unrelated. FWIW, I've always been against dummy-templatizing druntime/Phobos functions just for the sake of providing symbols for the crappy -betterC semantics. If builds are supposed to remain fast, then why would I need to analyze and codegen some common math functions for every debug build, if the 3 float variants can be handled via prebuilt overloads to be linked from a library? If we manage to untangle the druntime and Phobos deps, then -betterC semantics could at one point include linking a pay-as-you-go druntime, where such math functions would be taken from, without dragging in all the rest.

@rikkimax
Copy link
Contributor

If we manage to untangle the druntime and Phobos deps, then -betterC semantics could at one point include linking a pay-as-you-go druntime, where such math functions would be taken from, without dragging in all the rest.

Actually I've been thinking about this very issue, we already link in per binary an object file, why not include some other stuff with it with GC'able sections?

Note: I mentioned -betterC as that is how I found it. Great way to find issues such as this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants