Skip to content

cpu/mips: Integrate better with RIOT newlib layer#6639

Closed
jnohlgard wants to merge 11 commits intoRIOT-OS:masterfrom
jnohlgard:pr/mips-newlib
Closed

cpu/mips: Integrate better with RIOT newlib layer#6639
jnohlgard wants to merge 11 commits intoRIOT-OS:masterfrom
jnohlgard:pr/mips-newlib

Conversation

@jnohlgard
Copy link
Member

@jnohlgard jnohlgard commented Feb 22, 2017

Depends on #4699 #6066 #6092 #6670 #6672 #6673

  • Copied the relevant parts of mipshal.mk from the toolchain
  • Cleaned up CFLAGS and more in Makefile.include
  • Added empty syscalls implementation which can be used to interface with the UHI system, in reference to mips: Build system is not aligned with other platforms #6588 (comment)
  • Added a note on why -std=gnu99 is necessary for this CPU presently, should be removed once the toolchain is updated to a more recent newlib version.

The reason for this PR is that we need VFS (#5616) to be able to tell when newlib is used in order to provide the correct headers for use in statvfs etc.

@jnohlgard jnohlgard added Type: cleanup The issue proposes a clean-up / The PR cleans-up parts of the codebase / documentation Area: build system Area: Build system Platform: MIPS Platform: This PR/issue effects MIPS-based platforms labels Feb 22, 2017
@jnohlgard jnohlgard added this to the Release 2017.04 milestone Feb 22, 2017
# A bit of makefile magic:
# foreach symbol in overridable ld-symbols :
# If symbol has a value, produce a linker argument for that symbol.
MIPS_HAL_LDFLAGS = $(foreach a,$(priv_symbols),$(if $($a),-Wl$(comma)--defsym$(comma)__$(call lc,$(a))=$($a)))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The above block is basically the only thing that had any effect for our use case in mipshal.mk, all other CFLAGS and tool paths were already copied to this file in the initial MIPS PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably want to add this too:

ifdef ROMABLE
MIPS_HAL_LDFLAGS += -T bootcode.ld
endif

As we use the toolchain bootcode for PIC32.

@jnohlgard
Copy link
Member Author

references #6588

export APP_START=0x80000000

include $(MIPS_ELF_ROOT)/share/mips/rules/mipshal.mk
# Portable 'lowercase' func.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While this looks definitely beautiful, we're using $(shell echo X | tr 'A-Z' 'a-z') in many other places. Mental note to myself: analyze what is faster and then unify.

@kaspar030
Copy link
Contributor

The changes look fine and very necessary. Thanks @gebart!

@neiljay Could you test this?

@neiljay
Copy link
Contributor

neiljay commented Feb 24, 2017 via email

@jnohlgard
Copy link
Member Author

I found an issue. The Makefile.include for sys/newlib does not seem to be included with this patch. Need to investigate

@jnohlgard
Copy link
Member Author

jnohlgard commented Feb 24, 2017 via email

export CFLAGS_DBG = -O0 -g2
export CFLAGS_OPT = -Os -g2
export CFLAGS_DBG = -g3
export CFLAGS_OPT = -Os
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can be useful to have debug symbols on a release build too, the elf is typically converted to some binary format for 'real world' targets anyway.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@neiljay you have misinterpreted the intent of the CFLAGS_DBG and CFLAGS_OPT variables in the other Makefiles, they are simply groupings for making the file easier to read:

  • CFLAGS_DBG contains flags which affect the generation of debug symbols
  • CFLAGS_OPT contains flags which affect the code optimization
    If you check the other platforms you'll see that they are both unconditionally added to CFLAGS.
    We don't have any concept of Release build vs. Debug build in the current RIOT build system.
    I forgot to remove the comment on CFLAGS_DBG below, though.

@neiljay
Copy link
Contributor

neiljay commented Feb 27, 2017

@gebart @kaspar030

I've tried this change with a few of the examples and it hasn't broken anything, I had a couple of minor review points, but otherwise I'm happy with this as long as we can merge #6066 and #6092 first then rebase this atop.

Cheers.

Neil.

@neiljay
Copy link
Contributor

neiljay commented Mar 1, 2017 via email

@jnohlgard jnohlgard added the State: waiting for other PR State: The PR requires another PR to be merged first label Mar 1, 2017
@jnohlgard
Copy link
Member Author

rebased on top of #6092

@jnohlgard jnohlgard mentioned this pull request Mar 6, 2017
55 tasks
@neiljay
Copy link
Contributor

neiljay commented Mar 10, 2017

@gebart

I have checked this works on the pic32-clicker and pic32-wifire boards.

I guess this needs re-basing now the VFS PR got merged.

@jnohlgard
Copy link
Member Author

I will try to rebase this some time during the evening or weekend

@jnohlgard jnohlgard added CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR CI: needs squashing Commits in this PR need to be squashed; If set, CI systems will mark this PR as unmergable and removed CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Mar 11, 2017
@jnohlgard
Copy link
Member Author

rebased

Joakim Nohlgård added 7 commits March 30, 2017 09:23
 - Copied the relevant parts of mipshal.mk from the toolchain
 - Cleaned up CFLAGS and more in Makefile.include
 - Added empty syscalls implementation which can be used to interface
   with the UHI system
 - Added a note on why -std=gnu99 is necessary for this CPU presently
Some headers in the tool chain cause compilation errors with Clang in
assembly mode.
Causes compilation error on Clang
@jnohlgard
Copy link
Member Author

rebased on latest #4699, #6670

@neiljay
Copy link
Contributor

neiljay commented Mar 30, 2017

@gebart, Is it possible for me to commit directly to the PR, or should I create my own based off this ?
I have a tracking branch setup tracking gebart/pr/mips-newlib can I just push to that ?

@jnohlgard
Copy link
Member Author

@neiljay AFAIK it's not possible for you to update my PR branch, but if you would like to take over this PR you can open a new PR with your own branch and I'll close this one.

@jnohlgard
Copy link
Member Author

Closing in favour of #6892

@jnohlgard jnohlgard closed this Apr 11, 2017
@jnohlgard jnohlgard deleted the pr/mips-newlib branch October 25, 2018 16:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: build system Area: Build system CI: needs squashing Commits in this PR need to be squashed; If set, CI systems will mark this PR as unmergable Platform: MIPS Platform: This PR/issue effects MIPS-based platforms State: waiting for other PR State: The PR requires another PR to be merged first Type: cleanup The issue proposes a clean-up / The PR cleans-up parts of the codebase / documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants