Skip to content

Various improvements #102

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

Merged
merged 35 commits into from
Apr 23, 2020
Merged

Various improvements #102

merged 35 commits into from
Apr 23, 2020

Conversation

top-sekret
Copy link
Contributor

Various improvements enhancing psptoolchain

XZ archives are more modern and smaller.
…tool

The libtool script is installed in a separate package on some systems
and is not necessary for psptoolchain.
This is the most modern version of GCC. It also brings new C++ versions.

patch-gcc_cp_cfns.h is not needed anymore, because the new GCC version
uses C++, which removes the sole purpose of that file. I've also
disposed of old GCC patches.

I've added ISL to GCC build, because it seems to provide some
optimizations.
@dsieradzki
Copy link

Hello, you have to also fix "prepare scripts", I had to manually install isl on MacOS (brew install isl)

@top-sekret
Copy link
Contributor Author

I think it tries to load both includes and libs from the build root (the use of $(pwd) is misleading, I'd introduce variables like $srcdir and $builddir).

@top-sekret
Copy link
Contributor Author

top-sekret commented Dec 16, 2018

I also think that if the same fix were applied to GMP, MPFR and MPC, there would be no need to install them manually on the system.

@carstene1ns
Copy link
Member

Have you tested the new gcc?

@top-sekret
Copy link
Contributor Author

@carstene1ns yes, the SDK was built successfully, newlib was built successfully and so were the libraries

I mean, there was not a big load of changes in the patches. I've been trying to port new binutils, but this one is a bigger deal.

Also, I think GCC 8 is a good idea, because it can highlight visually (not only by character positions) which part of the line causes a warning/error.

@carstene1ns
Copy link
Member

Sure, using a new GCC brings a lot of benefits. Would be nice to know, if a compiled example works on hardware.

Also fix srcdir/builddir usage.

This effectively removes the dependency on GMP, MPFR, MPC and ISL
installed on the machine.
@top-sekret
Copy link
Contributor Author

top-sekret commented Dec 16, 2018

I would have to look for my hardware 😆. Anyway, I'm just finishing getting rid of some of errors you've highlighted.

EDIT: I've pushed two more commits. The first one fixes ISL build problems and makes the build process not require GMP, MPFR, MPC or ISL. The second one removes repeated MIPS_ATYPE_HI.

Also made it a little more verbose. A skeleton was added for future
support of more package managers on Linux.

The system does not use sudo (generally, such scripts should not use
sudo), but issues a warning if sudo is not used where it should. The
warning message is customized for the system.

Removed dependency for automake 1.9 - it is no longer in Debian, which
means it's high time the package using it was updated.

The script is now safe to be run with a shell other than bash, like dash.
The shebang on the top was changed to #!/bin/sh.
@dsieradzki
Copy link

dsieradzki commented Dec 16, 2018

Unfortunately I have compilation error on MacOS High Sierra 10.13.4:
`xgcc: error: addsf3: No such file or directory

make[2]: *** [addsf3.o] Error 1

make[2]: *** Waiting for unfinished jobs....

xgcc: error: subsf3: No such file or directory

make[2]: *** [subsf3.o] Error 1

xgcc: error: negsf2: No such file or directory

make[2]: *** [negsf2.o] Error 1`

@top-sekret
Copy link
Contributor Author

top-sekret commented Dec 17, 2018

@dsieradzki that's worth some investigation. Try building a compiler manually (get the tarball, configure and make it manually) to see if it is an issue in macOS or in my build scripts.

I've gotten it to work in a Docker container, so this is definitely not a dependency issue.

@carstene1ns
Copy link
Member

Might be a race condition/dependency issue with parallel builds.

@top-sekret
Copy link
Contributor Author

top-sekret commented Dec 17, 2018

@carstene1ns I'm building a huge script update and I opt for building one task at a time by default and only selecting more tasks if requested.

Then we can focus on making it work normally and just drop in some fixes for parallel builds later.

Also I believe the number of issues depends on the number of parallel jobs.

EDIT: I'd even dare say the issue is random.

  * Changed the scripts to work under any shell, not just Bash. As a
    side task, removed all these spaces at the beginning of the files.
    This wasn't funny, really.

  * Reworked dependency scripts. Now they're verbose, but I guess they
    will be silenced later.

  * Completely new&shiny toolchain.sh! Accepting options on command line
    and not using environment variables, this one is completely usable
    with no intervention. Things like PSPDEV or PATH are set based on
    the command-line options. Of course, toolchain-local.sh and
    toolchain-sudo.sh have been reworked accordingly and work perfectly
    with new toolchain.sh.

  * Removed all usages of sudo. This is NOT a command a script should
    run. The script instead warns of invalid UID.

  * Removed all usages of unzip. No ZIP archives are used at the moment
    and the unzip tool is not standarized and does not support stripping
    the prefix (I guess it could be done by hand, but it would be a
    mess).

  * Removed num_cpus from common.sh. Now scripts should take the number
    of jobs from the $JOBS variable, set by toolchain.sh. This allows to
    customize the number of jobs to one's liking.

  * Removed common.sh from toolchain.sh. export -f is a nonstandard
    feature anyway. Now each script that needs common.sh includes it. I
    guess some functions from there could be removed later.

  * Added run_make to common.sh. This allows to customize options to
    make in one place. Also removed the -r flag from make because this
    seems to wreck readline build.

  * Parametrized most build scripts (for example, 007-gdb-7.3.1.sh was
    changed to 007-gdb.sh and the version is defined in a variable in
    the file header).

  * Merged all the patches for all packages into two patches:

      - pkg-version-PSP.patch
        PSP support patch

      - pkg-version-fixes.patch
        Bug fix patch (like wrong compiler options, etc.)

    Not all packages have the fixes patch. For these that have it, its
    existence is optional and checked.

  * Disposed of /etc/profile generation script. It was weird and did
    some assumptions about the host.

  * Git repository cloning algorithm now checks if the repository is
    already cloned, is not corrupted and is has the same remote URL.
    Only then pulls. This should help guard against older repositories.
    Also changed merge pull to rebase pull.

  * Various minor changes.
@top-sekret
Copy link
Contributor Author

top-sekret commented Dec 18, 2018

OK I've pushed the scripting system rework.

I've tested it and it works. It's not from scratch, but only a rework of the existing tools, so I guess there shouldn't be any problems.

I'm going to use it for local testing and if someone made a GitLab
mirror, it would automatically start testing.
@top-sekret
Copy link
Contributor Author

I've created a Docker image for building PSP toolchain (not containing PSP toolchain). It can be used to build and run PSP toolchain in a deterministic, lean and supported environment.

You can view it here, but as I said these are only the dependencies of PSP toolchain, not the actual toolchain.

@top-sekret top-sekret mentioned this pull request Apr 11, 2019
GTgunner and others added 3 commits October 6, 2019 21:17
Fixed readline.h dependency check on Manjaro.
The if check gave an error if $USER is not set.
@dbeef dbeef self-assigned this Apr 4, 2020
@top-sekret
Copy link
Contributor Author

I see the repo has become active again. If I cherry-pick all relevant commits, will this get merged? @dbeef

@top-sekret
Copy link
Contributor Author

Because the problem I see is that new changes are made against the old scripts, which in turn causes the scripts from this pull request to have conflicts.

@dbeef
Copy link
Member

dbeef commented Apr 23, 2020

@top-sekret I was thinking about this PR, as you already noticed there are multiple conflicting changes introduced.

Thus you definitely have to rebase your GCC script changes, as it has been upgraded to 9.3.0, and the newlib as of now is shipped from pspdev/newlib.

For the .gitlab-ci.yml file, I don't see the point in including it without actually setting up the CI.
Github supports so called Actions and I imagine that this, connected with pspdev/docker will eventually run the CI, but this is only to be done in the future.

Here's how I see it - as there is a ton of changes in shell scripts, a development branch would be created on pspdev/psptoolchain, merging your changes there (granted you resolve conflicts), spending some time testing for regressions and then finally merging to master.

I am calling @carstene1ns and @ooPo to discuss this, as this is only an opinion of mine.

@top-sekret
Copy link
Contributor Author

top-sekret commented Apr 23, 2020

@dbeef OK, I've updated GCC and Newlib. I've also removed GitLab CI.

sdl-config was removed from the checks on my branch long ago.

I will address the stale automake patch in a minute, and this seems to be the last commit to rebase since I've forked.

@top-sekret
Copy link
Contributor Author

I've ported all changes to my fork.

@dbeef
Copy link
Member

dbeef commented Apr 23, 2020

Ok, so now @ooPo please create development branch out of the legacy one (I have not high enough permissions to do so).
Then target branch for this PR must be changed to pspdev/development, will probably merge without conflicts.

I upgraded to just the last version I could get before 2.24 because 2.24
was a nontrivial rewrite. Addressing 2.24 will be a matter of its own.
@dbeef dbeef changed the base branch from master to development April 23, 2020 16:31
@dbeef dbeef merged commit 699b0b1 into pspdev:development Apr 23, 2020
@dbeef
Copy link
Member

dbeef commented Apr 23, 2020

Merged to development branch. Half way done, now we need to do some testing.

I invite you to the PSP homebrew discord server, there's a channel called psp-toolchain where relevant discussions take place.

EDIT: Wrong link, mistakenly sent "PlayStation Homebrew" server, not PSP specific.

https://discord.gg/k4dmHd

@carstene1ns
Copy link
Member

I am in for merging specific changes, but I generally dislike stuff like "here, take my script. it is better than yours".
For example the readme stuff cannot be applied like it is (mentions specific stuff for this fork).
The merging of the gcc stage scripts and xz extraction are simple enough to add right away, but I am not fond of the "improved" dependency and preparation script.

@sharkwouter
Copy link
Member

sharkwouter commented Apr 24, 2020

To add to what @carstene1ns is saying about the dependency script, yesterday night I found that the current dependency installation script for Ubuntu can be run in an automatic way, while the one in this PR will always need user input. The current script for installing MacOS dependencies is really old and probably doesn't even work anymore, though, while the one in the PR should work better for that.

@top-sekret
Copy link
Contributor Author

@carstene1ns I am sorry. I did not intend to express such an attitude, but I believe you may be right, so my apologies for it.

When it comes to the Docker image, I believe the official Docker image didn't exist back then when I wrote it. You're absolutely right that it needs to be fixed. I can even do it if you point me to the correct Docker image.

When it comes to the dependency script, I separated it into sections and filtered it a little. If it introduces some unnecessary dependencies or does not check for some required, then I can fix it.

I rewrote the preparation script to unify it for all platforms. Regardless whether your doubts concern the script itself or the dependency lists contained inside, just let me address these issues. @sharkwouter Could you show me at what stage it requests user input? Would it be fixed by adding the -y option to apt?

After all, that's the point of development branch — it's not ready yet and I'm ready to work and collaborate on it and fix any issues that pop up.

@top-sekret
Copy link
Contributor Author

top-sekret commented Apr 24, 2020

Also, I just noticed, the else part in code below should never occur, as curl is bundled on macOS. So it will only be triggered if someone messed up the system or $PATH.

if command -v wget >/dev/null 2>&1

			if command -v wget >/dev/null 2>&1
			then
				wget --continue -O libusb-legacy.tar.gz "$LIBUSB_URL"
			elif command -v curl >/dev/null 2>&1
			then
				curl --continue-at - -o libusb-legacy.tar.gz "$LIBUSB_URL"
			else
				cat >&2 <<_EOF_
Error: no suitable downloader found.
Install one of these:
  * wget (preferred) <https://www.gnu.org/software/wget/>
  * curl <https://curl.haxx.se/>
_EOF_
				exit 77
			fi

@sharkwouter
Copy link
Member

I rewrote the preparation script to unify it for all platforms. Regardless whether your doubts concern the script itself or the dependency lists contained inside, just let me address these issues. @sharkwouter Could you show me at what stage it requests user input? Would it be fixed by adding the -y option to apt?

Yes, it asks you if you're sure when running apt install. I wasn't sure if this is intended, the original script does this too. The difference is that you can pass arguments to the original script, so you can just run sudo ./prepare-debian-and-ubuntu.sh -y. Not sure if that's what the script is called, but you get the idea.

This was referenced May 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants