This is an archive of the discontinued LLVM Phabricator instance.

[Flang] Fix build failure on MacOS
ClosedPublic

Authored by kiranchandramohan on Aug 12 2021, 9:14 AM.

Details

Summary

std::clock_t can be an unsigned value on some platforms like MacOS and therefore needs a cast when initializing an std::clock_t value with -1.

There is a CI failing in https://github.com/flang-compiler/f18-llvm-project/pull/625/checks?check_run_id=3293634051

Attempted fix in https://github.com/llvm/llvm-project/pull/333 and https://github.com/llvm/llvm-project/pull/334.

Also reported by @AlexisPerry.

Diff Detail

Event Timeline

kiranchandramohan requested review of this revision.Aug 12 2021, 9:14 AM
klausler added inline comments.Aug 12 2021, 9:22 AM
flang/runtime/time-intrinsic.cpp
39

You don't need move construction of the result of the cast.

Fix comment by @klausler to not use the move constructor.

kiranchandramohan marked an inline comment as done.Aug 12 2021, 9:34 AM
klausler accepted this revision.Aug 12 2021, 9:35 AM
This revision is now accepted and ready to land.Aug 12 2021, 9:35 AM
erichkeane added inline comments.Aug 12 2021, 9:37 AM
flang/runtime/time-intrinsic.cpp
39

Note this was a function-style cast, which is a no-op here, not a move construction! Still good to omit it however.

This revision was landed with ongoing or failed builds.Aug 12 2021, 10:15 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptAug 12 2021, 10:15 AM
dim added a comment.Aug 12 2021, 11:15 AM

Thanks. This should be merged to 13.0.0, if possible.

Meanwhile, if I may take a moment of your attention, I ran into this particular error (narrowing {-1} to clock_t) while doing the 13.0.0 rc1 builds for i386-freebsd, i.e. 32-bit x86. Since I encountered a whole lot of other issues where 32 and 64 bit quantities were mixed, does it make sense at all to attempt to build flang on 32-bit systems?

My guess is that this was never a goal, and 64 bit systems (i.e. LP64) are really the only support targets?

Thanks. This should be merged to 13.0.0, if possible.

I have asked @tstellar to cherry-pick this over to release/13.x since I ran into this when testing -rc1 on macOS. In the future I recommend you file an issue that is a blocker for the current release so it get's picked up by the release manager.

Thanks. This should be merged to 13.0.0, if possible.

Meanwhile, if I may take a moment of your attention, I ran into this particular error (narrowing {-1} to clock_t) while doing the 13.0.0 rc1 builds for i386-freebsd, i.e. 32-bit x86. Since I encountered a whole lot of other issues where 32 and 64 bit quantities were mixed, does it make sense at all to attempt to build flang on 32-bit systems?

My guess is that this was never a goal, and 64 bit systems (i.e. LP64) are really the only support targets?

Could @sscalpone or @klausler or @schweitz take this question?

Thanks. This should be merged to 13.0.0, if possible.

I have asked @tstellar to cherry-pick this over to release/13.x since I ran into this when testing -rc1 on macOS. In the future I recommend you file an issue that is a blocker for the current release so it get's picked up by the release manager.

Sure. Thanks for your help here @thieta.

Thanks. This should be merged to 13.0.0, if possible.

Meanwhile, if I may take a moment of your attention, I ran into this particular error (narrowing {-1} to clock_t) while doing the 13.0.0 rc1 builds for i386-freebsd, i.e. 32-bit x86. Since I encountered a whole lot of other issues where 32 and 64 bit quantities were mixed, does it make sense at all to attempt to build flang on 32-bit systems?

My guess is that this was never a goal, and 64 bit systems (i.e. LP64) are really the only support targets?

Could @sscalpone or @klausler or @schweitz take this question?

@dim I did not get a chance to discuss this with everyone. But my understanding is that at the moment we test only for 64 bit systems. Support for 32 bit systems (I think) is not ruled out but is not of immediate interest.

dim added a comment.Aug 19 2021, 12:27 PM

Thanks. This should be merged to 13.0.0, if possible.

Meanwhile, if I may take a moment of your attention, I ran into this particular error (narrowing {-1} to clock_t) while doing the 13.0.0 rc1 builds for i386-freebsd, i.e. 32-bit x86. Since I encountered a whole lot of other issues where 32 and 64 bit quantities were mixed, does it make sense at all to attempt to build flang on 32-bit systems?

My guess is that this was never a goal, and 64 bit systems (i.e. LP64) are really the only support targets?

Could @sscalpone or @klausler or @schweitz take this question?

@dim I did not get a chance to discuss this with everyone. But my understanding is that at the moment we test only for 64 bit systems. Support for 32 bit systems (I think) is not ruled out but is not of immediate interest.

Thank you! This was just out of interest, to see if I could add the flang component to my FreeBSD release builds for 32-bit x86. (For x86_64 I did not encounter build issues in flang itself, except maybe for a few warnings.)

I think it might be quite some effort to make it buildable on 32-bit systems, since I've seen that flang uses many 'index' variables which are declared explicitly as int64_t or uint64_t, and these are freely mixed with size_t's. You'd have to carefully go over all of these to see where you can cleanly convert back and forth...