Page MenuHomeFreeBSD

Allow building bin/cat on non-FreeBSD systems
ClosedPublic

Authored by arichardson on Jan 16 2018, 7:40 PM.

Details

Summary

cat -l is needed during the installworld phase and other system's cat
don't support that flag. To avoid portability issues when compiling on
Linux/macOS (such as the the direct access to &fp->_mbstate), we
disable the entire multibyte support when building as a boostrap tool.

Diff Detail

Repository
rS FreeBSD src repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

arichardson created this revision.Jan 16 2018, 7:40 PM

Came from rS305841.

bin/cat/cat.c
253–256 ↗(On Diff #38052)

How do other systems behave here? I worry that just addressing the compilation error (_mbstate) is insufficient, and we should have a different block (or perhaps just not support multibyte encoding on !FreeBSD)?

This patch was enough to make cat work enough to run installworld on Linux. But probably removing the whole wide stuff when not building for FreeBSD is better.

The other option here would be to write a small, portable build tool that take a file argument, opens and locks the file, and writes anything on stdin to the file until EOF.

Disable all flags except -l/-u when bootstrapping

arichardson edited the summary of this revision. (Show Details)Nov 15 2019, 3:54 PM
emaste accepted this revision.Jan 5 2020, 5:25 PM

This still feels a little icky to me but OK.

This revision is now accepted and ready to land.Jan 5 2020, 5:25 PM
brooks accepted this revision.EditedJan 6 2020, 5:58 PM

This seems fine.

We got cat -l from NetBSD when I implemented the METALOG work. I do wonder if a dedicated (and easily bootstrapable) tool would make more sense.

I agree that a small separate tool would be nicer. I don't really have time to write one right now though. I'll wait before committing this until it's the last blocker for cross-building. Maybe by then I'll find some time to add a write_locked (or whatever name we want to choose) bootstrap tool.

arichardson planned changes to this revision.Jan 10 2020, 2:50 PM

I'll wait before committing this until it's the last blocker for cross-building.

In fact I think it's fine to commit this now, perhaps expanding the comment before main() mentioning the alternate path. We can always revert if the other approach makes it in.

This revision was not accepted when it landed; it landed in state Changes Planned.Jan 16 2020, 2:15 PM
This revision was automatically updated to reflect the committed changes.