Bug 18515 – freebsd 11 ships with gcc unable to link 32 bit binaries, dmd uses it by default

Status
NEW
Severity
critical
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
FreeBSD
Creation time
2018-02-24T04:51:35Z
Last change time
2024-12-13T18:57:22Z
Assigned to
No Owner
Creator
Brad Roberts
Moved to GitHub: dmd#19398 →

Comments

Comment #0 by braddr — 2018-02-24T04:51:35Z
DMD uses 'gcc' to perform the link step. On freebsd 11 (and likely other earlier versions, unexplored), gcc -m32 fails to link, looking at 64 bit library paths instead. This combination results in freebsd 11 32 non-functional. Either 'clang' or 'cc' work just fine. For the auto-testers, they're currently running with CC set to cc in their environment. That's not particularly acceptable an out of the box experience for users of that platform. IMHO, DMD needs to use 'cc' by default rather than gcc. Without having double checked, I suspect that will work on any relatively modern platform without causing regressions.
Comment #1 by issues.dlang — 2018-02-24T08:32:20Z
Looking at the source code for the compiler, the only place I see that the CC environment variable is used is in src/dmd/link.d, and it looks like back in October, Martin changed it so that it uses cc if CC is not set, and if I have neither gcc nor g++ in my PATH on my 64-bit FreeBSD system, it compiles just fine. I know that that didn't used to be the case, but it appears to be so now - presumably thanks to Martin's changes to link.d. So, I don't know why the auto-tester would be trying to use gcc or g++. There is some logic in posix.mak where it tries to figure out whether clang or gcc is being used - primarily so that it can figure out which compiler flags to use, I think. Glancing over it, it looks like it uses c++ --version to figure that out, though if HOST_CXX is set, it uses that instead of c++, and it might use CXX if that's set. So, maybe the problem with the auto-tester relates to the makefile somehow? Certainly, from what I can tell, the issue is not as simple as dmd using gcc by default now if CC isn't set. Does the environment for the autoster have CC, CXX, HOST_CC, or HOST_CXX set to gcc or g++?
Comment #2 by issues.dlang — 2018-02-24T09:13:08Z
However, it does look like test/d_do_test.d hardcodes g++ if CC isn't set, so that fails if g++ isn't available.
Comment #3 by bugzilla — 2018-02-24T09:25:00Z
Yes, the dmd code: https://github.com/dlang/dmd/blob/master/src/dmd/link.d#L420 shows that dmd is simply reading the CC environment variable. So it's something else that is setting CC to gcc.
Comment #4 by issues.dlang — 2018-02-24T10:06:52Z
Comment #5 by github-bugzilla — 2018-02-24T22:09:17Z
Commits pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/0527f4eef35b56afd67c65382a0e395d86db93f4 issue 18515: Fix it so that neither g++ nor CC is required. It was previously fixed so that cc is used if CC isn't set when compiling dmd, but the test suite still had g++ hardcoded, so if the system was set up with clang and not gcc, the dmd test suite barfed midway through. This fixes it so that it uses c++ if CC isn't set instead of using g++. https://github.com/dlang/dmd/commit/bd2465510a172414cc626f7d7ebc3d0db8aece3f Merge pull request #7949 from jmdavis/issue_18515 issue 18515: Fix it so that neither g++ nor CC is required.
Comment #6 by braddr — 2018-02-24T22:14:14Z
I wasn't thinking about this last night, but the behavior that's in question isn't master or stable branch, but rather 2.068.2. That compiler's behavior is where things are going wrong. The problem, as far as the auto-tester is concerned, has been worked around sufficiently. I'm not sure if there's any remaining issues with the tip of tree builds.
Comment #7 by issues.dlang — 2018-02-25T00:56:13Z
Well, I'm able to build and run the tests for Phobos, druntime, and dmd without having gcc installed on a 64-bit FreeBSD 11.1 system. I'd guess that that works for 32-bit as well (aside from the test failures that are being worked through), but I don't know. 2.068.2 certainly won't work that way though.
Comment #8 by github-bugzilla — 2018-04-06T21:05:07Z
Commits pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/5f4d97ce92f7715d71dc53724ae655f3060c542b issue 18515: Fix it so that neither g++ nor CC is required. It was previously fixed so that cc is used if CC isn't set when compiling dmd, but the test suite still had g++ hardcoded, so if the system was set up with clang and not gcc, the dmd test suite barfed midway through. This fixes it so that it uses c++ if CC isn't set instead of using g++. https://github.com/dlang/dmd/commit/77b3d453a49f908e0e09e192852c198dc4c3787f Merge pull request #8012 from wilzbach/fix-win32-64-stable [stable] issue 18515: Fix it so that neither g++ nor CC is required.
Comment #9 by robert.schadek — 2024-12-13T18:57:22Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/19398 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB