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

uClibc and -checkaction=C #3078

Closed
sarneaud opened this issue May 28, 2019 · 4 comments

Comments

@sarneaud
Copy link

commented May 28, 2019

uClibc's assert() implementation uses a 4-parameter __assert() function, like the __assert_fail() function in other libcs.

Currently ldc2 doesn't recognise uClibc and falls back to generating code for a 3-parameter __assert(). I don't see an easy fix because LLVM's target triples don't seem to support uClibc.

@kinke

This comment has been minimized.

Copy link
Member

commented May 28, 2019

I don't see an easy fix because LLVM's target triples don't seem to support uClibc.

We have this as workaround for that:

ldc/driver/main.cpp

Lines 536 to 545 in 7474c19

void fixupUClibcEnv() {
llvm::Triple triple(mTargetTriple);
if (triple.getEnvironmentName().find("uclibc") != 0)
return;
std::string envName = triple.getEnvironmentName();
envName.replace(0, 6, "gnu");
triple.setEnvironmentName(envName);
mTargetTriple = triple.normalize();
isUClibc = true;
}

This isUClibc is currently only used to set the predefined version CRuntime_UClibc. We'd need to adapt this too:

ldc/gen/runtime.cpp

Lines 378 to 390 in 5e5ce19

static std::vector<PotentiallyLazyType> getCAssertFunctionParamTypes() {
const auto voidPtr = Type::tvoidptr;
const auto uint = Type::tuns32;
if (global.params.targetTriple->isOSDarwin() ||
global.params.targetTriple->isOSSolaris() || isMusl()) {
return {voidPtr, voidPtr, uint, voidPtr};
}
if (global.params.targetTriple->getEnvironment() == llvm::Triple::Android) {
return {voidPtr, uint, voidPtr};
}
return {voidPtr, voidPtr, uint};
}

@rracariu

This comment has been minimized.

Copy link
Contributor

commented May 29, 2019

uClibc will work at least ARM and MIPS were tested to some extent, see the status issues: #2995 and #2810 - MIPS still has issues with ABI compatibility but this is not related to uClibc.

To enable uClibc support the triple looks like armv6-hardfloat-linux-uclibceabi or mipsel-unknown-linux-uclibc

@sarneaud

This comment has been minimized.

Copy link
Author

commented May 29, 2019

@rracariu Thanks, but this is specifically a problem with -checkaction=C and uClibc, not uClibc support in general.

@rracariu

This comment has been minimized.

Copy link
Contributor

commented May 30, 2019

@sarneaud OK, got it. Then exposing isUClibc outside main.cpp should work.
Maybe have a helper function similar to isMusl()

kinke added a commit to kinke/ldc that referenced this issue May 31, 2019

@kinke kinke closed this in #3082 May 31, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.