Skip to content

Conversation

@WalterBright
Copy link
Member

No description provided.

@dlang-bot
Copy link
Contributor

Thanks for your pull request, @WalterBright!

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 fetch digger
dub run digger -- build "master + dmd#8257"

* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/backend/dvec.d, backend/dvec.d)
*/


Copy link
Contributor

Choose a reason for hiding this comment

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

Should there be a module declaration?

Copy link
Member Author

Choose a reason for hiding this comment

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

The module name defaults to the file name.

Copy link
Contributor

Choose a reason for hiding this comment

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

I know that but all other D files in DMD has a module declaration.


static assert(vec_base_t.sizeof==2 && VECSHIFT==4 ||
vec_base_t.sizeof==4 && VECSHIFT==5 ||
vec_base_t.sizeof==8 && VECSHIFT==6);
Copy link
Contributor

Choose a reason for hiding this comment

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

Would be nice with a space around the operators.

void vec_set(vec_t v)
{
if (v)
{ memset(v, ~0, v[0].sizeof * vec_dim(v));
Copy link
Contributor

Choose a reason for hiding this comment

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

Braces on their own lines.

@jacob-carlborg
Copy link
Contributor

The Visual Studio project file is not updated.

@wilzbach
Copy link
Contributor

wilzbach commented May 18, 2018

Regarding the Jenkins failure - the Ocean failure is unrelated.
See dlang/ci#208 (after the next push, Jenkins should be green again).

* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/backend/dvec.d, backend/dvec.d)
*/

module dvec;
Copy link
Member

Choose a reason for hiding this comment

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

Should be module dmd.backend.dvec, otherwise separate compilation fails.

Copy link
Member Author

Choose a reason for hiding this comment

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

Aye, there's the rub. I cannot make this work for both dmc and dmd, because they use separate directory structures. Upgrading the boot compiler to 2.079 is required. Unfortunately, this has been blocked for a year now, and is currently blocked by:
#8249
#8112

Copy link
Member

Choose a reason for hiding this comment

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

I haven't yet heard a convincing reason why dmc and dmd should not share a common directory structure, e.g. use module name tk.dvec and put it into the respective folder. Not using package names is unlikely to be a good idea for shared modules.

Copy link
Member Author

Choose a reason for hiding this comment

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

The reason is:

  1. It's a lot of nuisance work for me to crowbar dmc into a totally different directory structure - messing up the git history, changing all the imports, etc.
  2. I'm the one doing the work, and this is the way I want to do the work, because mashing it into multiple directories is unproductive for me.
  3. All the blocking items for making this work are inconsequential and do not negatively impact anything else.
  4. All the blocking items are things we need to do anyway (like support the -mv command). I can hardly be the only one who wants to share the same modules among multiple projects.
  5. assert() support in 2.068 is so heavy it is disabled in dmd, with various negative consequences that show up now and then. The back end relies heavily on asserts being ON. 2.079 has much better support for lightweight assert().

Copy link
Contributor

@dnadlinger dnadlinger May 18, 2018

Choose a reason for hiding this comment

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

I cannot make this work for both dmc and dmd, because they use separate directory structures.

As I mentioned before, this isn't necessarily an issue. If you really can't be bothered [1] to choose a standard directory structure, just keeping them in the top-level package like this is fine (as long as it is actually used as import dvec;).

All the blocking items for making this work are inconsequential and do not negatively impact anything else.

If one were to e.g. regard -betterC as a badly designed command line switch, then supporting it does negatively impact e.g. GDC, as it adds complexity that can't easily be gotten rid of again.

All the blocking items are things we need to do anyway (like support the -mv command). I can hardly be the only one who wants to share the same modules among multiple projects.

People usually prefer to use non-surprising directory structures for this.

assert() support in 2.068 is so heavy it is disabled in dmd, with various negative consequences that show up now and then. The back end relies heavily on asserts being ON. 2.079 has much better support for lightweight assert().

Just replace assert() by a custom template then. Trivial to do during the translation.


[1] Note that moving src/{ddmd -> dmd} came with many more issues (src/dmd being used by the executable, files also used from GDC/LDC), yet you were happy to agree to that.

Copy link
Contributor

Choose a reason for hiding this comment

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

I could have had the back end converted a year ago. Instead I spend time on this back and forth over a trivial blocker.

You keep repeating this claim, yet all these "blockers" are trivially worked around. If you were really interested in converting the backend, you could have done just that a year ago. Your earlier statement applies verbatim: "It's also TRIVIAL. I simply cannot understand the resistance to it."

As I've pointed out elsewhere, I believe the only such workaround that would require code changes is that to support "release asserts". Any time you might need to spend writing a sed script/… to convert those assert calls to a custom function is entirely dwarfed by the time it takes to do the conversion itself, or indeed the required changes to all the various build systems that go with it.

So, can we please stop pretending that "I need it to convert the backend to D" is a valid argument in favour of bumping the bootstrap compiler version requirement? If you'd like to change the version requirements to make your life easier, I'm not sure why you would need to make up bogus reasons to ask for that. Your word still carries weight here.

Copy link
Member Author

Choose a reason for hiding this comment

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

sed scripts

Adding more technical debt is to be avoided, not embraced. Never mind that sed isn't a standard tool on Windows, so I'd have to write a program to do that, and check it into the repositories. I know what I think when I see such things in other projects.

trivial

Yes, I could write a script to copy directory structures around before each compile. Is that something you'd want to do for your project? I prefer to avoid rube goldberg build setups. (Heaven knows the build system is fragile enough as it is.)

pretending

I'm used to doing ugly things to get things to work when I have no choice. I've even resorted to writing programs to patch object files. But there's no reason to do that here. The advantage to owning the tool chain is the fix can be put in the right spot.

Your word still carries weight here.

Then please pull the blocking PRs.

Copy link
Contributor

@dnadlinger dnadlinger May 19, 2018

Choose a reason for hiding this comment

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

sed scripts

Adding more technical debt is to be avoided, not embraced. Never mind that sed isn't a standard tool on Windows

Replacing assert with my_assert is a one-time thing, to be done along with many other mechanical changes during the C -> D conversion.

trivial

Yes, I could write a script to copy directory structures around before each compile.

No need for that, as explained before. Just keep the backend modules in the root package (as in this PR) if you don't want to deal with directories. That's possibly not the prettiest thing to do, but then you are the one who is arguing for a flat structure.

I'm used to doing ugly things to get things to work when I have no choice.

Imho both -betterC and -mv are such ugly things, but that's somewhat besides the point here. What even are the ugly things that you would need to accept in order to use an old D version?

Naming a non-standard assert something different isn't really one, at least in my opinion. A different name can be gainfully employed to highlight (and explain via a DDoc comment) the special requirements for backend use (small code/always enabled/…).

Then please pull the blocking PRs.

One is failing, and @kinke seems to have a valid suggestion for the other one.

Copy link
Member Author

Choose a reason for hiding this comment

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

I had my own non-standard assert for years in the back end. I finally removed it along with a lot of other garbage I used to think was a good idea.

Copy link
Member Author

Choose a reason for hiding this comment

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

One is failing,

Because it's blocked by the other.

and @kinke seems to have a valid suggestion for the other one.

Regardless of the merit of his suggestion, it requires delaying for multiple release cycles.

@@ -1,446 +1,443 @@
<?xml version="1.0" encoding="utf-8"?>
Copy link
Member

@rainers rainers May 18, 2018

Choose a reason for hiding this comment

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

This is probably converting CRLF to LF. This should not happen for the VC project files.

Copy link
Member Author

Choose a reason for hiding this comment

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

Changed it back to CRLF.

@jacob-carlborg
Copy link
Contributor

Is there a reason for changing the name from vec to dvec?

else
{
v = cast(vec_t) calloc(dim + 2, vec_base_t.sizeof);
assert(v);
Copy link
Member

Choose a reason for hiding this comment

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

This should better be reporting "out of memory", the backend uses err_nomem() for this.

Copy link
Member Author

Choose a reason for hiding this comment

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

It uses the assert because the file is supposed to be independent of any other project modules. The C++ version it was translated from did this, too.

Copy link
Member

Choose a reason for hiding this comment

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

The C++ version uses mem_calloc/mem_exception from mem.c.

assert(v) has the problem that it is likely to go away in a release build, so if you want no dependencies I'd recommend if (!v) assert(false, "out of memory").

Copy link
Member Author

Choose a reason for hiding this comment

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

See my other comment about why assert not being disabled is required in the back end.

else
{
vc = cast(vec_t) calloc(nbytes, 1);
assert(vc);
Copy link
Member

Choose a reason for hiding this comment

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

Same here.

Otherwise, translation looks good.

/**
* Compiler implementation of the
* $(LINK2 http://www.dlang.org, D programming language).
*
Copy link
Contributor

Choose a reason for hiding this comment

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

I suggest adding a description of the module. I have no idea what the code in this file does. Also, a more descriptive file name wouldn't hurt

@WalterBright
Copy link
Member Author

@CyberShadow can you please upgrade the boot compiler on CyberShadow/DAutoTest to 2.079 so this passes?

@CyberShadow
Copy link
Member

DAutoTest is already set up to use 2.079 once #8112 is merged.

Do you want to merge this PR before #8112? If so, I could change the detection logic enabling a newer host compiler to check for dvec.d instead of -mv in the makefile.

@WalterBright
Copy link
Member Author

Do you want to merge this PR before #8112?

Yes, please. #8112 is not a blocker for this, it's just a canary for needed features in the boot compiler.

@CyberShadow
Copy link
Member

Done, should take effect on the next rebuild.

@WalterBright
Copy link
Member Author

@CyberShadow thanks! It's working now, ready to pull!

Copy link
Contributor

@JinShil JinShil left a comment

Choose a reason for hiding this comment

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

There are a lot of valid concerns voiced in the review of this PR, but Walter has addressed most of it and made his decision. I think it's time to move on; some things can even be addressed after the conversion to D.

@WalterBright WalterBright merged commit 6817246 into dlang:master Jun 1, 2018
@WalterBright WalterBright deleted the dvec.d branch June 1, 2018 01:23
@quickfur
Copy link
Member

quickfur commented Jun 3, 2018

This PR broke my local dmd build, which bootstraps with 2.069:

../generated/linux/release/64/backend.a(dvec.o): In function `_D4dvec9VecGlobal9terminateMUNbNiZv':
/mnt/1/usr/src/d/dmd/src/dmd/backend/dvec.d:65: undefined reference to `_D4dvec8__assertFiZv'
/mnt/1/usr/src/d/dmd/src/dmd/backend/dvec.d:67: undefined reference to `_D4dvec7__arrayZ'
/mnt/1/usr/src/d/dmd/src/dmd/backend/dvec.d:76: undefined reference to `_D4dvec7__arrayZ'
../generated/linux/release/64/backend.a(dvec.o): In function `_D4dvec9VecGlobal8allocateMUNbNimZPm':
/mnt/1/usr/src/d/dmd/src/dmd/backend/dvec.d:87: undefined reference to `_D4dvec7__arrayZ'
/mnt/1/usr/src/d/dmd/src/dmd/backend/dvec.d:89: undefined reference to `_D4dvec7__arrayZ'
/mnt/1/usr/src/d/dmd/src/dmd/backend/dvec.d:106: undefined reference to `_D4dvec8__assertFiZv'
../generated/linux/release/64/backend.a(dvec.o): In function `_D4dvec9VecGlobal3dupMUNbNixPmZPm':
/mnt/1/usr/src/d/dmd/src/dmd/backend/dvec.d:131: undefined reference to `_D4dvec7__arrayZ'
/mnt/1/usr/src/d/dmd/src/dmd/backend/dvec.d:133: undefined reference to `_D4dvec7__arrayZ'
/mnt/1/usr/src/d/dmd/src/dmd/backend/dvec.d:138: undefined reference to `_D4dvec8__assertFiZv'
../generated/linux/release/64/backend.a(dvec.o): In function `_D4dvec9VecGlobal4freeMUNbNiPmZv':
/mnt/1/usr/src/d/dmd/src/dmd/backend/dvec.d:162: undefined reference to `_D4dvec7__arrayZ'
/mnt/1/usr/src/d/dmd/src/dmd/backend/dvec.d:163: undefined reference to `_D4dvec7__arrayZ'
../generated/linux/release/64/backend.a(dvec.o): In function `vec_setbit':
/mnt/1/usr/src/d/dmd/src/dmd/backend/dvec.d:269: undefined reference to `_D4dvec8__assertFiZv'
../generated/linux/release/64/backend.a(dvec.o): In function `vec_clearbit':
/mnt/1/usr/src/d/dmd/src/dmd/backend/dvec.d:280: undefined reference to `_D4dvec8__assertFiZv'
../generated/linux/release/64/backend.a(dvec.o): In function `vec_testbit':
/mnt/1/usr/src/d/dmd/src/dmd/backend/dvec.d:299: undefined reference to `_D4dvec8__assertFiZv'
../generated/linux/release/64/backend.a(dvec.o): In function `vec_andass':
/mnt/1/usr/src/d/dmd/src/dmd/backend/dvec.d:348: undefined reference to `_D4dvec8__assertFiZv'
/mnt/1/usr/src/d/dmd/src/dmd/backend/dvec.d:349: undefined reference to `_D4dvec8__assertFiZv'
../generated/linux/release/64/backend.a(dvec.o):/mnt/1/usr/src/d/dmd/src/dmd/backend/dvec.d:355: more undefined references to `_D4dvec8__assertFiZv' follow
collect2: error: ld returned 1 exit status
--- errorlevel 1
make[1]: *** [posix.mak:475: ../generated/linux/release/64/dmd] Error 1
make[1]: Leaving directory '/mnt/1/usr/src/d/dmd/src'
make: *** [posix.mak:8: all] Error 2

Checking out the revision before this PR was merged fixes the problem.

@WalterBright
Copy link
Member Author

You'll need to upgrade your boot compiler.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants