Skip to content
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

[WIP] msp430-elf crosscompiler #3336

Merged
merged 4 commits into from
Sep 5, 2019
Merged

[WIP] msp430-elf crosscompiler #3336

merged 4 commits into from
Sep 5, 2019

Conversation

mojca
Copy link
Member

@mojca mojca commented Jan 5, 2019

Description

This is an attempt to bring the old cross-compilers (msp430-gcc[-devel] and msp430-binutils[-devel]) up to date, but I didn't actually test the functionality (I'm not actually sure how to test), and some stuff might be missing.

I could potentially push the changes in crossbinutils and crossgcc earlier than those for the msp cross-compiler.

What annoys me most and I would be grateful for some feedback/suggestions/brainstorming: I hate the way patching is done. The patches for binutils, gcc, newlib, gdb all come together in a single .tar.bz2 file which basically contains four relatively big patch files.

  • I would be slightly tempted to extract those files and put them to files/, but at least for gcc they are too massive to warrant this simplification.
  • I tried to manually extract the patches and then using full path to them, like:
    patchfiles ${workpath}/${name_patch}/binutils-2_26.patch
    but this failed to work as MacPorts tried to search for that patch inside files/, or maybe tried to fetch it from the website etc.
  • I could extract all the patches and temporarily attach them to a trac ticket or somewhere else, so that the port could fetch them from some random URL.
  • MacPorts in theory supports bzcat directly (out-of-the-box), the only problem is that the tarball contains patches for four different pieces of software and patching everything together fails.
    Yet another ugly aspect is that the same file with patches (in the way it's currently done) ends up in several different directories inside distfiles (binutils, gcc, gdb).

What else is missing:

  • If @g5pw and others agree, I would make the old msp430* ports obsolete (I would do some commit history edit magic).
  • It would probably make sense to make the ports openmaintainer (see also mspdebug: update to 0.25, switch to github #3339).
  • I decided to use the name msp430-elf because the build instructions mention using --target=msp430-elf. I don't actually know to what extent this distinction makes any difference, if any at all.
  • I need feedback about the naming of support files (currently msp430-gcc-support-files).
  • The gdb port is still missing (I suspect that all the old ports are broken on newer OSes, so that's not so critical yet, but it should be done). I started playing with a crossgdb PortGroup, but there's still quite some stuff missing and I cannot get the includes for gettext done right.
  • The *.specs files from newlib are not installed:
    > msp430-elf-gcc -mmcu=msp430g2211 -specs=nosys.specs -o test.elf test.c
    msp430-elf-gcc: error: nosys.specs: No such file or directory
    
  • Someone would need to double-check the required configure flags.
  • It would be great to actually test the crosscompiler.
  • It could be nice (but nobody else does that yet) to enable gcc's own test.

@g5pw @MarcusCalhoun-Lopez @raimue

Tickets

Closes: https://trac.macports.org/ticket/44009
Closes: https://trac.macports.org/ticket/44010
Closes: https://trac.macports.org/ticket/49323
Closes: https://trac.macports.org/ticket/50571
Closes: https://trac.macports.org/ticket/56109
Closes: https://trac.macports.org/ticket/57238
See: https://trac.macports.org/ticket/56887

Type(s)
  • bugfix
Tested on

macOS 10.13.6 17G3025
Xcode 10.1 10B61

Verification

Have you

  • checked your Portfile with port lint?
  • tried existing tests with sudo port test?
  • tried a full install with sudo port -vst install?
  • tested basic functionality of all binary files?

@macportsbot macportsbot added by: member Created by a member with commit rights type: submission labels Jan 5, 2019
@mojca mojca mentioned this pull request Jan 5, 2019
11 tasks
@macportsbot
Copy link

Travis Build #4775 Failed.

Lint results
--->  Verifying Portfile for msp430-elf-binutils
--->  0 errors and 0 warnings found.
--->  Verifying Portfile for msp430-elf-gcc
--->  0 errors and 0 warnings found.
--->  Verifying Portfile for msp430-gcc-support-files
Warning: Line 25 should use the expansion operator instead of the eval procedure. Change
Warning:     eval xinstall -m 644 [glob ${worksrcpath}/include/*.h]  ${installdir}/include
Warning: to
Warning:     xinstall -m 644 {*}[glob ${worksrcpath}/include/*.h]  ${installdir}/include
Warning: Line 26 should use the expansion operator instead of the eval procedure. Change
Warning:     eval xinstall -m 644 [glob ${worksrcpath}/include/*.ld] ${installdir}/lib
Warning: to
Warning:     xinstall -m 644 {*}[glob ${worksrcpath}/include/*.ld] ${installdir}/lib
Error: Missing required variable: description
Error: Missing required variable: long_description
Error: Missing required variable: categories
Error: Missing required variable: maintainers
Error: Missing required variable: platforms
Error: Failed to lint msp430-gcc-support-files: can't read "maintainers": no such variable
Error: See /opt/local/var/macports/logs/_Users_travis_build_macports_macports-ports_cross_msp430-gcc-support-files/msp430-gcc-support-files/main.log for details.
Error: Follow https://guide.macports.org/#project.tickets to report a bug.
Error: Processing of port msp430-gcc-support-files failed

Port msp430-elf-binutils success on xcode9.4. Log
Port msp430-elf-gcc fail on xcode9.4. Log
Port msp430-gcc-support-files success on xcode9.4. Log
Port msp430-elf-binutils success on xcode8.3. Log
Port msp430-elf-gcc fail on xcode8.3. Log
Port msp430-gcc-support-files success on xcode8.3. Log
Port msp430-elf-binutils success on xcode7.3. Log
Port msp430-elf-gcc fail on xcode7.3. Log
Port msp430-gcc-support-files success on xcode7.3. Log
Port msp430-elf-binutils success on xcode10.1. Log

@macportsbot
Copy link

Travis Build #4777 Passed.

Lint results
--->  Verifying Portfile for msp430-elf-binutils
--->  0 errors and 0 warnings found.
--->  Verifying Portfile for msp430-elf-gcc
--->  0 errors and 0 warnings found.
--->  Verifying Portfile for msp430-gcc-support-files
--->  0 errors and 0 warnings found.

Port msp430-elf-binutils success on xcode9.4. Log
Port msp430-elf-gcc success on xcode9.4. Log
Port msp430-gcc-support-files success on xcode9.4. Log
Port msp430-elf-binutils success on xcode8.3. Log
Port msp430-elf-gcc success on xcode8.3. Log
Port msp430-gcc-support-files success on xcode8.3. Log
Port msp430-elf-binutils success on xcode7.3. Log
Port msp430-elf-gcc success on xcode7.3. Log
Port msp430-gcc-support-files success on xcode7.3. Log
Port msp430-elf-binutils success on xcode10.1. Log

@mojca
Copy link
Member Author

mojca commented Jan 5, 2019

I tried following https://gist.github.com/0/631c9006a672458eaa48, but it seems that the specs files are missing:

> msp430-elf-gcc -mmcu=msp430g2211 -specs=nosys.specs -o test.elf test.c
msp430-elf-gcc: error: nosys.specs: No such file or directory

They are apparently not installed by newlib?

@pmetzger
Copy link
Member

pmetzger commented Jan 6, 2019

Are we sure anyone wants to use these?

@macportsbot
Copy link

Travis Build #4807 Passed.

Lint results
--->  Verifying Portfile for msp430-elf-binutils
--->  0 errors and 0 warnings found.
--->  Verifying Portfile for msp430-elf-gcc
--->  0 errors and 0 warnings found.
--->  Verifying Portfile for msp430-gcc-support-files
--->  0 errors and 0 warnings found.

Port msp430-elf-binutils success on xcode9.4. Log
Port msp430-elf-gcc success on xcode9.4. Log
Port msp430-gcc-support-files success on xcode9.4. Log
Port msp430-elf-binutils success on xcode8.3. Log
Port msp430-elf-gcc success on xcode8.3. Log
Port msp430-gcc-support-files success on xcode8.3. Log
Port msp430-elf-binutils success on xcode7.3. Log
Port msp430-elf-gcc success on xcode7.3. Log
Port msp430-gcc-support-files success on xcode7.3. Log
Port msp430-elf-binutils success on xcode10.1. Log
Port msp430-elf-gcc success on xcode10.1. Log
Port msp430-gcc-support-files success on xcode10.1. Log

@mojca
Copy link
Member Author

mojca commented Jan 7, 2019

Are we sure anyone wants to use these?

We have 7 tickets open with requests to update or fix them (ok, one is from me, which leaves 6 others) which does kind of send a signal that some people are eager to use these tools. I do occasionally use various cross-compilers myself as well, even if I don't currently have any hardware of this particular sort (@g5pw said I could borrow it temporarily from him to test the crosscompiler :)

@DanielO
Copy link
Contributor

DanielO commented Mar 29, 2019

I want to use these (and the GDB port) and have the tools & hardware to test them.
Is there a guide for how I can use your tree to build them for testing?
Thanks.

@mojca
Copy link
Member Author

mojca commented Mar 31, 2019

There are plenty of ways, but my suggestion would be to clone the full macports-ports repository and configure ${prefix}/etc/macports/sources.conf to use that as source of ports, according to https://guide.macports.org/chunked/development.local-repositories.html

One simple option would be to copy and manually apply the patch:
https://github.com/macports/macports-ports/pull/3336.patch

Alternatively you could fetch the changes via

git remote add mojca https://github.com/mojca/macports-ports.git
git fetch --all
git checkout --track mojca/msp430-elf

which you can later delete (but in any case make sure that you switch back to master branch later). I hope I didn't mess up with instructions.

Make sure you got the right contents, run portindex in the tree and then try to install the port(s) from there.

@DanielO
Copy link
Contributor

DanielO commented Mar 31, 2019

I think there are some files missing on install, eg..

[Maelstrom-1122 9:43] ~/projects/msp430_launchpad >msp430-elf-gcc -mmcu=msp430g2553 main.c
cc1: warning: devices.csv not found on any include paths.
   Please obtain the latest version of the msp430-gcc-support-files archive from:
"http://software-dl.ti.com/msp430/msp430_public_sw/mcu/msp430/MSPGCC/latest/index_FDS.html"
and place the full path to the "include" directory containing devices.csv on an include path specified with -I
Defaulting to the hard-coded device data...
/opt/local/lib/gcc/msp430-elf/7.3.2/../../../../msp430-elf/bin/ld: cannot find crt0.o: No such file or directory
/opt/local/lib/gcc/msp430-elf/7.3.2/../../../../msp430-elf/bin/ld: cannot find -lcrt
/opt/local/lib/gcc/msp430-elf/7.3.2/../../../../msp430-elf/bin/ld: cannot find -lnosys
collect2: error: ld returned 1 exit status

I suppressed the devices.csv one by pointing it at the Ti version I had from their tools (ie /Applications/ti/ccsv8/ccs_base/msp430/include_gcc/devices.csv).

The code I am testing is https://www.instructables.com/id/Getting-started-with-TIs-MSP430-gcc-and-the-MSP430/ if you want to replicate (I have some of my own code but that example is nice and simple and publicly available)

Edit: I checked the port build products and there is no crt0.o - I see newlib-2.4.0/libgloss/msp430/crt0.S, and can build it OK. If I use it, then I still complains about missing libcrt and libnosys. If I use -nostdlib it then complains about undefined references to WDTCTL etc..

Edit2: I just realised the linker script has all those defined so this works..

msp430-elf-gcc main.c -mmcu=msp430g2553 -o main.o -c -Wall -O2
msp430-elf-gcc /opt/local/var/macports/build/_Users_oconnd1_projects_macports-ports_cross_msp430-elf-gcc/msp430-elf-gcc/work/newlib-2.4.0/libgloss/msp430/crt0.S -mmcu=msp430g2553 -o crt0.o -c -Wall -O2
msp430-elf-ld crt0.o main.o -o main.elf -T /opt/local/msp430-elf/lib/msp430g2553.ld

(Works == compiled, haven't tried real code as yet :)

@mojca mojca mentioned this pull request May 7, 2019
11 tasks
@KubaO
Copy link
Contributor

KubaO commented Jun 17, 2019

Are we sure anyone wants to use these?

We have 7 tickets open with requests to update or fix them (ok, one is from me, which leaves 6 others) which does kind of send a signal that some people are eager to use these tools. I do occasionally use various cross-compilers myself as well, even if I don't currently have any hardware of this particular sort (@g5pw said I could borrow it temporarily from him to test the crosscompiler :)

I use those and not having an up-to-date port is a bummer. Would love to have one!

@cjones051073
Copy link
Member

cjones051073 commented Aug 25, 2019

@mojca What do you want to do with this PR ? We should either merge or close it, not let it linger around.

@pmetzger
Copy link
Member

Agreed. No point in having it sit in the pull queue for a year if it isn't going to be pulled.

@mojca
Copy link
Member Author

mojca commented Aug 26, 2019

We could also merge it and fix the remaining problem with some missing files later. I suspect this might need an extra bootstrapping phase, but I need some help/expertise/ideas.

@mojca
Copy link
Member Author

mojca commented Aug 26, 2019

Maybe add port notes about remaining problem.

@pmetzger
Copy link
Member

@mojca It's up to you of course. If you want to merge it, do that. If you prefer closing, do that.

@g5pw
Copy link
Contributor

g5pw commented Aug 29, 2019

I think we should merge this, and deprecate the msp430- ones. Me and @mojca will test with some boards to verify that this works properly.

@cjones051073
Copy link
Member

where do we now stand with this ?

@mojca mojca merged commit 72620c5 into macports:master Sep 5, 2019
@ricardo119
Copy link

Hi, I add a ticket in the MacPorts forum and found out that the problem I had it's not new (https://trac.macports.org/ticket/69841?cversion=1&cnum_hist=3#comment:3). But I'm new in the Mac ecosystem and can't figure out what can I do to fix the problem while downloading msp430-gcc. Can someone help me out?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
by: member Created by a member with commit rights maintainer type: bugfix type: submission wip Work in progress
9 participants