-
Notifications
You must be signed in to change notification settings - Fork 153
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
build process -- Food for thought #42
Comments
You could try reaching out to the mailing list, there may be more people subscribed than those that are watching this git repo. To subscribe, try sending a plain text email to [email protected] with the word "help" in the body and follow the instructions you receive. (Note, the mailmain web server is no longer working, but it will respond to email commands.) What part of the build is failing and what errors are you getting? I did not think that anything ultimately depended on bash, however there may be bash-specific work-arounds in the generic bourne-shell compatible scripts. eg. in bin/package As for the use of curl and wget, they aren't 100% necessary either because hurl.sh (src/cmd/INIT/hurl.sh) can fall back to using /dev/tcp/$HOST/$PORT style connections if it's running under bash or ksh and it can't find curl or wget. I recently looked into the build failures for: cmd/kshlib/dss only to come to the conclusion that the dss builtin has been broken for a while and needs rewriting because the API version of nvapi has changed. And I'm not yet sure why cmd/kshlib/cmdtst tests are failing, but I doubt that it is needed any more because the grep and xargs builtins are integrated and working fine now in src/lib/libcmd. I have been looking at getting the ast repo building automatically with travis ci, but currently bin/package test has over 680 errors on a working build on my linux machine! I am thinking that some of those tests may need to be removed or silenced until they pass reliably. We don't have access anymore to the ast build farm to build on multiple platforms, but at least travis ci can test on linux and macos: https://docs.travis-ci.com/user/multi-os/ So I think that those platforms should be first-class platforms that have to be able to build and test without errors. We may also be able to get an x86-based Solaris system in a virtual machine somewhere building automatically as well as freebsd, darwin and even cygwin. We should also start to document how to debug the build system in the github wiki. |
Siteshwar from Redhat now has commit access to the repo and has added a PR for freebsd #19 that might help, as OSX is based on BSD I believe. Also, he has added a travis file to the beta branch, but it is currently only targeting fedora and is not yet running any tests. |
I personally quite like the build system here, although I have yet to fully wrap my head around it (I am currently debugging a problem related to Manpages are no longer on line, I think getting documentation online and some introductory material would help. I have even made my own little "release" including #19 - I was surprised how quick and easy it was. |
Man pages are readable here: https://web.archive.org/web/20151104235435/http://www2.research.att.com/~astopen/download/ Then visit: AST, nmake, overview |
FWIW, I used ksh88 then ksh93 for more than two decades when I worked for Sequent Computer Systems. Then switched to zsh when I changed jobs. I then abandoned zsh when I realized the zsh architecture was broken beyond repair. After two years of contributing to the Fish shell project I've abandoned it for several reasons. Primarily because it seems like the big problems with its implementation (e.g., how I/O through pipelines is handled) will never be fixed. Also, because the current developers are expending effort on pointless changes such as changing So I was intrigued to see that the Korn shell had been open sourced and hosted on Github. But I can't figure out how to get a) better documentation for how to build ksh93 on macOS (google searches didn't yield any answers), or b) switching to a more modern build system like Cmake or autotools/autoconf. Admittedly the latter isn't very modern but it is more widely supported and understood than the AT&T |
I don't have access to an OS X machine, but I have put the build script that I use to compile ksh on fedora in notes here. Latest changes are in
|
The build usually proceeds even if the previous steps failed, so it is worth examining the build log from the top rather from bottom and find the issue there. |
@siteshwar, Thanks for that script. Just running
Your script actually results in a ./arch/darwin.i386-64/src/cmd/nmake directory being created but not
I should point out I have a hybrid macOS system since I have installed many GNU tools via Homebrew and have arranged for some of the GNU tools to shadow the macOS/BSD variants. But that has not generally been a problem when working with other open source software. On Ubuntu 16.10 just running I'll spend a little more time trying to get ksh to build on macOS but I'm not very motivated to do so since other shells (e.g., Elvish) build and run on macOS without jumping through hoops and are more likely to have a future. |
Seems like your shell is crashing, what is your |
Also, are there any errors in |
The first problem I found was an unwanted line wrap from cutting/pasting @siteshwar's script. Once I fixed that I found that symbols like There are several discussion threads about this header problem when building with the AST tools. Such as this one: https://mail-index.netbsd.org/netbsd-bugs/2014/07/14/msg037462.html. After working around the nl_types problem the build gets a lot farther and does generate a
Forcing /bin/sh to be used by using Sure enough. I enabled core dumps and what we see is that
|
Replacing
|
Okay, I fixed the
So we're back to the problem that the |
@krader1961 not sure I have a fix for this problem but in case you keep on troubleshooting the build I have a small collection of patches to make it build on FreeBSD. |
@saper, What I don't understand is why your PR is needed or why I am seeing compatibility problems building on macOS. I just booted my FreeBSD 12.0 virtual machine. I did
Is it the case that ksh93 on BSD systems has been broken for a long time? |
My PR #76 to fix the two places that don't handle overlapping buffers on BSD correctly plus @saper's PR #19 lets me build everything but Also, when I do |
I noticed
None of the commands or library code in the project use those functions. Obviously I picked those at random as they caught my eye while looking at the build log. There are hundreds of such feature tests that are not relevant for any of the code being compiled. If the |
Okay, I see my previous comment about math functions like |
Trying to build this project on macOS (a BSD variant) resulted in two `assert()` failures when running `nmake`. The problem is that there are at least two places which pass overlapping buffers to functions which are explicitly defined to have undefined behavior when the buffers overlap. See issue #42.
Symbol visibility is an important issue, that is why this simple patch may fix a lot on non-Linux platform. Regarding 12.0 I I would check if there was no API/ABI change, may happen as 12.0 is the unreleased -CURRENT. Maybe some other change broke it. |
fwiw i would also like to evaluate meson as a possible option for new build system. |
FWIW, I've been trying to figure out why I can build ksh93 with gcc but not clang on macOS. One reason is the use of
Clang treats it as an error:
There are other compiler options, such as This causes the AST build system to use the I've worked around those issues and have managed to build ksh93 with P.S., I've also noticed that the |
The fish-shell project discussed using Cmake and Meson here and ultimately chose Cmake. However, a couple of the reasons they rejected Meson don't apply to this project. And I do love that Meson is built on Python. However, as this blog article notes Meson introduces yet another way to build projects without solving any significant problems with Cmake and is much less mature. If we do go to the trouble of replacing the current build system we should not switch to autotools. While venerable, widely available, and lots of people are familiar with it (unlike nmake) it has almost as many quirks as our current build system and would not be much of an improvement. |
Unless their functionality has changed greatly in the last few years, please avoid using GNU autotools. Whenever you have to step off the beaten path, you plummet to the bottom of a ravine. They have way too many implicit and hidden dependencies. And they are a mess whenever trying to migrate software for new, evolving environments (OSes) or when cross-building software. |
For the record I have found the following to be the minimum set of files and directories needed to build
From src/cmd:
Obviously switching to Meson or Cmake would eliminate several of those. Using this bare minimum reduces the ksh93 build time roughly 25%. It's still obscenely slow because of all the redundant invocations of |
Haha! The person who wrote Meson wrote a blog article about the transition to Cmake at Canonical (the company that produces Ubuntu): https://blog.kitware.com/use-of-cmake-at-canonical/. Which makes me inclined to vote for switching to Meson for this project. 😄 |
I just spent a couple of hours reading various Reddit threads, Stackoverflow questions, and blog posts about the merits of Cmake versus Meson. For example, this article from July of this year is a strong thumbs up for Meson over Cmake. However, the article does end on this note:
Given that ksh93 is still trying to support ancient K&R compilers I'm wondering how much of a deal breaker the dependency on Python 3 is. Obviously we no longer need to support K&R (pre ANSI C) compilers. But what about old OS's like Solaris which may not have Python 3 available? |
@jelmd, I have no idea what I am supposed to do with that script you posted in your comment. You don't seem to understand that running |
I have been watching this thread and others for a while. Let me say THANK YOU for all the digging and testing. Though I still can't get a proper compile on macOS, I see progress thanks to your think tank actions. If I may, I would like to share my 2c thoughts on a recurring topic in this thread: replace the build system Getting the build process to work on modern (or current) platforms, is obviously a primary objective. However, already planning a build system revolution (i.e. change), besides not being respectuous of all the effort put in over decades by the folks at ATT, would not solve the build objective: understanding the dependancies of our code. All a build system does is enact a set of rules provided by the source package. Those rules poke the underlying system to understand its capabilities and available features. What we need in the community take over of a previously proprietarily maintained code, is to identify and document those rules. A blunt analogy: imagine you migrated to GNU autotools, but had no idea of what you had to writeup in Additionally, why would I replace an inventive build system that relies exclusively on the shell, by one that pulls in other dependencies (m4, Python, ...)? Knowing that those systems also do rely on the underlying shell. Simplicity? Clarity? Extensibility? Programming language ? ... The only real argument I would not be able to defend is opaqueness. Current utilities like Further, the portable shell constraint has also considerably contributed to the opaqueness of the code(d)... which compares here to the opaqueness of GNU autotools m4 macros for casual users. Reverse engineering seems to be (at least to me) the only way to go. I can understand that many may prefer starting from a new blank page, using either tools they know or the latest hype toolchain(c). So, as a POC of my meandering thoughts, I started a lab experiment with one of those opaque utilities which is often mentioned: My objectives are: a) Reverse engineer the I am only a couple of hours done the line. So no tangible results yet. However, first impressions are that, once restructured and simplified, That done, subsequent objectives would be: c) Build a modular and extensible system where user-contributed functions can simply be added to FPATH and made available to More on this as i progress on (a) And yes Korn shell is a capable programming language. David Korn's motivation was that a shell is "about string processing", and had ATT followed Richard Stallman's mouvance at the time, the Korn shell would have probably stalled Larry Wall's efforts and we would have enjoyed a CKAN rather than a CPAN :-) (b) Making the assumption that most current platforms have either a default (c) A little sarcasm here triggered by the self-promoted fullstack community re-inventing the wheel with tools like Grunt, Gulp and the like, taking the headlines all over the Web, despite those tools being more complex, less flexible, and less maintainable than grandpa's (d) I would be tempted to believe that these opaque tools are just the output of other tools, not made publicly available by ATT. Glen Fowler or Phong Vo could possibly answer this. |
@krader1961: 1) reading the full comment/context of the link, would make sense. IMHO one doesn't need to wonder, that you do not understand things, when you continue to just picking up some keywords or links w/o taking its context into account. 2) If you still not understand its purpose, as a experienced ksh programmer you should be able to find out, what the script does - so reading the script would be another option. 3) Simply executing/exploring what it does, would be an option, too. Wrt. nmake: because you obviously don't read the documentation of the software you wanna change, you still have not understood, that actually nmake is NOT required to build ksh93, and it also not needed to run the related tests (big hint: plz read at least the |
@marcastel: I 100% agree with all your points including footnotes. IMHO it is a good idea to do, what all other established langs do, i.e. use the own lang to build itself, because "real" bootstrapping from scratch is not needed anymore - all related systems seem to have a ksh93 package now. |
@marcastel, You said
That is not an accurate reflection of what I have said. I have repeatedly stated that AST Nmake is better than GNU autotools and other options available 10+ years ago. If my only choice is GNU autotools or AST Nmake I would choose the latter. Keep in mind that my arguments are focused solely on building There is absolutely no chance that this project will continue to depend on The current build rules are broken. I have experienced many instances where I'm willing to bet that I can convert building ksh to the Cmake or Meson build systems before you can implement your improvements to Nmake. Which, according to @jelmd, isn't even needed to build ksh. |
@krader1961, I was not pin pointing anybody. And I am indeed happy to hear that you feel sufficiently confident to transform, in a breeze from one system to another. Hoping that you will share that significant insight :-) While I do not support your urge to change the build system, I can understand it. In the meantime, I am pursuing my RE effort. I needed a linter, so here is an iffe parser which can parse iffe(5) syntax. It can output an abstract syntax language representation -- see sample below or full output which represents parsing of This abstract notation allows extreme flexibility with existing code -- BTW irrespective of the build system :-) It is still rough around the edges and I need to set up regression testing. But fairly confident this can get polished rapidly with more logging and debugging features. A by-product of this parser is that is could be used to semi-automatically document the feature probing done for AST components. |
PS: I also tried myself at an |
@marcastel, Can you provide links to any open source projects that are using the AST Nmake build system? I could not find any despite several hours of research. There may be private projects at companies or universities which are using it but those are not interesting since we can't examine them. Furthermore, they are unlikely to incorporate any improvements from this project to the Nmake build system. Also, neither myself or @siteshwar is
That is why we are working to remove source code not needed to build ksh. The result of that work will make it easier to understand what needs to be implemented in a new build system to support building ksh. |
PR #123 has been merged. That makes it possible to build libast using Meson. It is the first step in switching from Nmake to Meson for building and testing the |
Congratulations @krader1961 and al. I have been seing all the traffic, impressive. I'm still walking my way down the other line, nonetheless and have made good progress too. |
PR #124 has been merged. That makes it possible to build |
On my system ksh now gets built in around 1 minute which is a significant improvement over the legacy build system that took around 3 minutes. Most of this time is still taken by |
Trying to build this project on macOS (a BSD variant) resulted in two `assert()` failures when running `nmake`. The problem is that there are at least two places which pass overlapping buffers to functions which are explicitly defined to have undefined behavior when the buffers overlap. See issue #42.
I'm closing this since we are now using Meson to build/test ksh93 including on Travis CI environments. There is more work to be done to remove dependencies on the legacy |
For the record, when I got nmake to build in parallel and got my build down to 2m30, that was without Kurt's optimisation to skip testing for all the math library functions because my system must be missing some dependency. With that fixed, it would have been a lot faster, probably comparable to meson. iffe tests could probably have been split into separate files to enable more parallelism, though I never tested that. |
We have managed to remove all the @marcastel Thanks for opening this issue and your efforts to document |
I know I'm late into this discussion, as a decision was already taken. Anyway, if someday into the future anybody suggests changing the build system, let me say that I consider inconvenient the requisite to build Python before the shell (I'm talking about installing an OS from source). I'm just into a project that involves installing an OS from scratch, and we discarded ksh93 just because of the Python dependency (not that we hate Python, but we want the shell up and running before Python). Either standard make or CMake would fit better in the process of building an OS from scratch. |
That crossed my mind, too, so I continue to keep the old way and just cherry pick improvements if possible. |
@cesss Thanks for taking time to write. I can suggest you couple of solutions if you want to use ksh:
|
Thanks a lot. Yes, of course you usually need to employ binaries built in a previous stage when you are bootstrapping a new system, but we are following a simple/purist approach. In fact, if we reconsider it and adopt ksh, it will be by adding to it a build procedure that only uses tools that are available during the early stages of building a new OS from scratch. In that case (ie: if we reconsider and adopt ksh), we can do a pull request with the alternative build procedure if you accept pull requests. |
Somewhat notable changes in this commit: - The 'set +r' bugfix (re: 74b4162) is now documented in the changelog. - Missing options have been added to the synopsis section of the ksh man page. - The minor formatting fix from ksh-community/ksh#5 has been applied to the ksh man page. - A few fixes from att@5e747cfb have been applied to the ksh man page. - The man page fixes from att#353 have been applied, being: - An addition to document the behavior of 'set -H'. - A fix for the cd section appending rksh93. - A fix for some options being indented too far. - Removal of a duplicate section documenting '-D'. - Reordering the options for 'set' in alphabetical order. - A minor fix for the documentation of 'ksh -i'.
Should we change/adapt the build process?
(with the objective to make it easily maintainable and accessible to a greater number)
Small knowledgeable community
I know nobody amongst my fellow developers that has insight knowledge on the build process beyond
bin/package make
, let alone to maintain it, but simply to customise it. Neither do I.That said, they know how to maintain and tweak GNU Autotools and CMake toolchains.
Note: Do not jump to conclusions here, I am not trying to promote Autotools or CMake; quite the contrary. I simply want to emphasise the lack of openess of the build process' logic and toolchain.
Scarse documentation
Embedded usage documentation in any C or Korn shell script is a fantastic asset of the AST developments, and certainly immensely underused among users of AST packages.... except for the AST developers who have consistently added usage information to all their utilities.
Nonetheless that documentation does not suffice for a newbie to get his head round the build toolchain and gain sufficient insight information to act alone without calling out for help.
Today I am confronted with a failing build on a platform, which is certainly not exotic (MacOS), and I find myself spending hours trying to understand where the errors occur.
Unless told otherwise, I have no supporting information to help me get through my build failures. And calling out for help won't be of great help because ( I presume) only a few have invested significant time in understanding the guts of the toolchain. Questions will take time to be answered, if ever answered.
Build tool
When all goes well, the AST build toolchain seems to beat flat out the other tools mentioned above. It has (apparently) no dependencies, allows for all the GNU Autoconfigure probing without the M4 hell, and nicely lays out its build products.
Opinion: GNU Autotools are a fantastic suite. But they have a major inconvenience: M4. Opaque and to a certain extend clumsy. Probably a good compromise for portability 30 to 40 years ago. But no longer the ad hoc tool for today; pre-processing could be done the AST way :-)
Could the AST build toolchain be system agnostic and a possible replacement for GNU Autotools or CMake on other projects? A toolchain written in portable POSIX shell targeting any raw (POSIX) UNIX or Linux.
Whilst this was probably a driver in its conception, we see, going through the source files that it depend on
bash
here,lynx
orwget
there, etc. So it is not agnostic and doesn't build on a raw system; it requires GNUish capabilities. Hence it targets UNIX/GNU or Linux/GNU platforms.Note: for the reasoning let us ignore for now that we probably need
gcc
to avoid proprietary compilers (where such compilers still exist).Logically one can ask, why then maintain a distinct build toolchain? Why not use GNU Autotools or CMake?
Liminary thoughts
The breakup of the AST development team has (luckily) brought the AST developments to the open source community. But the community is small (and probably fragile).
If the AST packages and the Korn shell are here to stay, the community needs to be enlarged.
Enlarging the community means, making the build process accessible to many.
Migrating to GNU Autotools or CMake is an enormous effort which would require such time investment that it is almost guaranteed to stall.
Documentation and HOWTOs seems to be the only realistic approach. This also requires time, and reverse engineering.
Request for comments
In the 90s, shell portability was a big concern, and scripting had to focus on POSIX shells only (Korn shell wasn't a POSIX shell at the time, it now is).
Today, thanks to AT&T opening up the source code, a Korn shell exists on (almost) every platform. Not PDKSH or old versions, but a
ksh93
executable (whatever its release).Consequently, in 2017 onwards, we can assume that we have a Korn shell executable that supports the 93 syntax and features.
Converting the AST build toolchain scripts from universal shell syntax to Korn shell 93 syntax can:
a) greatly reduce the LOC (e.g.
iffe
could be reduced by 50%)b) allow for clean environments with the
function
keywords, limiting globalsc) break down the code into smaller and more maintainable chunks using FPATH
d) usage information can be added to all functions
This doesn't require a full reverse engineering effort, nor does it require a full rewrite of the code.
At the same time this allows for a learning curve which can be populated in HOWTO's and central documentation.
By doing this we can (re)gain knowledge of the AST build toolchain, document it properly for the community to get involved, and lead the way for a
ksh2023
rather than aksh93+z2023
:-)The text was updated successfully, but these errors were encountered: