A few notes about the devkit for Debian/Ubuntu users

If you have any questions on programming, this is the place to ask them, whether you're a newbie or an experienced programmer. Discussion on programming in general is also welcome. We will help you with programming homework, but we will not do your work for you! Any porting requests must be made in Developmental Ideas.
Post Reply
Chilly Willy
DC Developer
DC Developer
Posts: 414
https://www.artistsworkshop.eu/meble-kuchenne-na-wymiar-warszawa-gdzie-zamowic/
Joined: Thu Aug 20, 2009 11:00 am
Has thanked: 0
Been thanked: 2 times

A few notes about the devkit for Debian/Ubuntu users

Post by Chilly Willy »

I've run into this before, but many folks working on devkits make bash scripts. The problem is that Debian and any distro derived from Debian have been using dash for quite a few years. While dash strives for speed and POSIX compliance, bash keeps adding more and more non-standard features to tempt people to the Dark Side.

KOS uses bash scripts for gnu wrappers. For example, most makefiles for KOS projects use kos-cc for the compiler. That's not a program, it's a bash script.. one that is decidedly not POSIX compliant. So what's a Debian-derived distro user to do? In the end, I wound up switching back to bash. There's just too much work to make these devkits compatible with dash. In Ubuntu, you do this with

Code: Select all

sudo dpkg-reconfigure dash
That will pop up a box asking if you wish to use dash as the shell; select NO and it will instead make bash the default shell.

A further note - in the environ.sh script, you find this line:

Code: Select all

export KOS_CFLAGS="-O2 -fomit-frame-pointer"
When the gnu wrappers work, that line is added to your flags, which means that your project will always be built with those two flags. The O level will override any O level you select in your makefile. What I did was make a few extra environ.sh scripts: the first was environ_kos.sh for building kos and kos-ports; it changes -O2 to -O1, which is appropriate for any code that directly accesses hardware. The second was environ_fast.sh, which changes -O2 to -Ofast for projects where you want the general fast optimization. Finally, I made an environ_noflags.sh which makes the whole string "" so that your makefile isn't overridden for those two options. If you tend to use more flags regularly, you might make another environ shell script with them in the line. Just remember to source the script before building your project!
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5652
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has thanked: 9 times
Been thanked: 69 times
Contact:

Re: A few notes about the devkit for Debian/Ubuntu users

Post by BlueCrab »

A couple of things to note...

1. What in them does not work in dash? I just installed dash to see what might not work, but I didn't run into any problems with kos-cc or anything like that. Also, the line in kos-c++ that claims it needs bash seems to work just fine with dash... Note: this is with the most recent upstream release of dash, version 0.5.9.

2. I'd highly recommend that extreme caution be used with any optimization level above -O2. GCC seems to routinely break optimization on SuperH, and KOS hasn't been tested at any optimization levels above -O2. Simply put, if you use something above -O2, you're on your own... :wink:
Chilly Willy
DC Developer
DC Developer
Posts: 414
Joined: Thu Aug 20, 2009 11:00 am
Has thanked: 0
Been thanked: 2 times

Re: A few notes about the devkit for Debian/Ubuntu users

Post by Chilly Willy »

The for loop isn't supported according to a couple dash/bash difference pages I've read. Also some issues with the case statement. Under xubuntu 16.04 dash, the kos-cc script was never using the right USEMODE as far as my testing showed. It worked fine when I switched to bash... not that that cured any of the problems I've had recently. :)

And yes, you don't use higher than O2 until AFTER all the problems are solved. I generally like to stick to O1 as long as I'm debugging.
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5652
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has thanked: 9 times
Been thanked: 69 times
Contact:

Re: A few notes about the devkit for Debian/Ubuntu users

Post by BlueCrab »

Weird... That stuff should all be supported, according to the POSIX spec chapter on the shell language... At least by my reading of it, it should. Even the 2004 edition says that for loops and case statements should be supported. Perhaps it's just an issue in the version of dash that's in use in xubuntu for some reason? As I said, it appears to work just fine with Dash 0.5.9 on OS X...
Chilly Willy
DC Developer
DC Developer
Posts: 414
Joined: Thu Aug 20, 2009 11:00 am
Has thanked: 0
Been thanked: 2 times

Re: A few notes about the devkit for Debian/Ubuntu users

Post by Chilly Willy »

Hmm - this is the page I normally use for "fixing" scripts to work with dash. It's always worked for me so far.

http://mywiki.wooledge.org/Bashism

It says it was last updated on 2016-04-26.
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5652
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has thanked: 9 times
Been thanked: 69 times
Contact:

Re: A few notes about the devkit for Debian/Ubuntu users

Post by BlueCrab »

None of the stuff on that page suggests that the stuff in kos-cc should break. It doesn't use numeric for loops, nor does it use any of the oddities with case that are described there. Both 'for' and 'case' are part of the POSIX spec for shells, it's just some extensions in Bash that aren't -- in this case, C-style "for ((i = 0; i < 10; i++))"-like loops and drop-throughs on cases (or at least, that's what I assume the ;;& thing is for based on the description -- I've never actually seen that syntax at all that I can recall).
User avatar
bogglez
Moderator
Moderator
Posts: 578
Joined: Sun Apr 20, 2014 9:45 am
Has thanked: 0
Been thanked: 0

Re: A few notes about the devkit for Debian/Ubuntu users

Post by bogglez »

Maybe https://github.com/koalaman/shellcheck can help with this?
Wiki & tutorials: http://dcemulation.org/?title=Development
Wiki feedback: viewtopic.php?f=29&t=103940
My libgl playground (not for production): https://bitbucket.org/bogglez/libgl15
My lxdream fork (with small fixes): https://bitbucket.org/bogglez/lxdream
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5652
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has thanked: 9 times
Been thanked: 69 times
Contact:

Re: A few notes about the devkit for Debian/Ubuntu users

Post by BlueCrab »

Pretty much all that spits out is a bunch of messages about using double quotes (at least, the web-based version thereof only spits out that kind of stuff, and some stuff about variables not being defined -- but they're defined by the environ script, so that's harmless).

Thanks for the suggestion though. :)
Post Reply