can't compile on macos with lastest source code

104 views
Skip to first unread message

Jyeni Nii

unread,
Sep 5, 2019, 9:55:06 PM9/5/19
to NuttX
ζ make                                                            [19e1db3f97]
sed: 1: "/Volumes/Storage/Synolo ...": invalid command code S
make: *** [version_info] Error 1

ζ arm-none-eabi-gcc --version                                     [19e1db3f97]
arm-none-eabi-gcc (GNU Tools for Arm Embedded Processors 7-2018-q2-update) 7.3.1 20180622 (release) [ARM/embedded-7-branch revision 261907]

please help me, thanks.

patacongo

unread,
Sep 5, 2019, 10:27:55 PM9/5/19
to nu...@googlegroups.com
This is why I do not like to accept any changes to the build system.  Build system changes always break something for someone.

ζ make                                                            [19e1db3f97]
sed: 1: "/Volumes/Storage/Synolo ...": invalid command code S
make: *** [version_info] Error 1


I can't help you with macOS because I don't have a MAC.  So you will need to solve this yourself (and for all other macOS users).

This error was introduced by commit a0867a7f4f3ac2e4b34b3c3cd149b7ca6d8b712f which added the version_info target to tools/Makefile.unix and the bash script tools/gen_gitrev.sh

Something in that commit does not work on the MAC.  Can you help figure what does not work?  Please do these things:
  1. Review the changes in commit a0867a7f4f3ac2e4b34b3c3cd149b7ca6d8b712f 
  2. Make the code again using 'make V=1'.  That will provide you with a lot more information and will show the exact command line used to execute tools/gen_gitrev.sh
  3. Copy that command line and use it to run gen_gitrev.sh at the Bash prompt.  Is it the Makefile.unix changes that are failing, or the gen_gitrev.sh script.
My guess would be there there is an incompatibility in the gen_gitrev.sh script.  In order to have a portable Bash script, you must minimize the use of exotic Bash features.  That script does not do that.  It uses many of the more advanced Bash constructs and so it probably not portable.

You can then run the get_getrev.sh with debug enabled.  You can do this by either:
  1.  Addin sh -x before the script exeuction, or
  2. Just add temporarily add set -x at the beginning of the gen_getrev.sh file.
That will pinpoint exactly what in the script is failing.  Then you should be able to fixe the script for macOS.

I am not sure what else I can do you help you.  Unless you wan to buy me a MAC ;)



 

 

Jyeni Nii

unread,
Sep 6, 2019, 12:34:22 AM9/6/19
to NuttX
thanks patacongo, i will try it follow your tips

在 2019年9月6日星期五 UTC+8上午9:55:06,Jyeni Nii写道:

patacongo

unread,
Sep 6, 2019, 9:27:09 AM9/6/19
to NuttX



thanks patacongo, i will try it follow your tips

I hope that you can find the problem.  Otherwise, I will have to revert the commit.  It is more important that NuttX builds correctly on macOS than to have this feature.

patacongo

unread,
Sep 6, 2019, 9:30:58 AM9/6/19
to nu...@googlegroups.com


thanks patacongo, i will try it follow your tips

I hope that you can find the problem.  Otherwise, I will have to revert the commit.  It is more important that NuttX builds correctly on macOS than to have this feature.

 I suppose we could add another configuration option to disable collecting GIT information for the proc FS.  I really don't want to add more configuration information.  There are too many low-level, trivial configuration settings now.

Best to solve the problem.

David Alessio

unread,
Sep 6, 2019, 10:42:24 AM9/6/19
to NuttX
I have a Mac, I'll take a look today...  We'll fix it. 

Gregory Nutt

unread,
Sep 6, 2019, 10:45:04 AM9/6/19
to nu...@googlegroups.com

Best to solve the problem.


I have a Mac, I'll take a look today...  We'll fix it.

Thanks, David!

Greg


David Alessio

unread,
Sep 6, 2019, 5:00:18 PM9/6/19
to NuttX
Jyeni,

Please post more lines from the error output.  It's not clear to me where or why this is failing, except there appears to be a problem invoking the 'sed' utility.

Regards,
-david

patacongo

unread,
Sep 6, 2019, 7:25:22 PM9/6/19
to NuttX
Makes me wonder how many other build platforms are broken.  I tried with Linux, Cygwin, and MYS2.  It appears to work on all of those.  macOS is know broken.  How about FreeBSD/NetBSD and Solaris?  Windows native?  There have been users on all of those in the past.  Since masOS has a BSD heritage, I would suspect there are issues there?  Can anyone confirm that things are building okay on those platforms? or not.

patacongo

unread,
Sep 6, 2019, 7:35:33 PM9/6/19
to NuttX


Please post more lines from the error output.  It's not clear to me where or why this is failing, except there appears to be a problem invoking the 'sed' utility.

Also use 'make V=1' so that we can see what is happening, not just the final error.

patacongo

unread,
Sep 6, 2019, 8:18:33 PM9/6/19
to NuttX

"The major problem is that the MacOS coreutils are FreeBSD-based while the utilities you are used to are most likely from the GNU project. The FreeBSD coreutils are not always compatible with the GNU coreutils. There are performance and behavioral differences between the GNU and FreeBSD versions of sed, grep, ps, and other utilities."

patacongo

unread,
Sep 6, 2019, 8:39:09 PM9/6/19
to NuttX


On Friday, September 6, 2019 at 6:18:33 PM UTC-6, patacongo wrote:

"The major problem is that the MacOS coreutils are FreeBSD-based while the utilities you are used to are most likely from the GNU project. The FreeBSD coreutils are not always compatible with the GNU coreutils. There are performance and behavioral differences between the GNU and FreeBSD versions of sed, grep, ps, and other utilities."

There is only one use of sed in this commit and that is in tools/Makefile.unix  at line 89.  It is a 'sed -i'.  That is, I believe the cause of the problem.


Notice that the BSD sed -i option requires an argument, the GNU sed -i option does not.  So the edit-in-place is not portable.  I believe that is what must be changed.

Jyeni, can you please test this.  Just comment out line 289 in tools/Makefile.unix?  That is not a fix, but tell us if that the 'sed -i' is the culprit.

 

Lwazi

unread,
Sep 7, 2019, 12:35:22 AM9/7/19
to NuttX


On Friday, 6 September 2019 09:27:09 UTC-4, patacongo wrote:



thanks patacongo, i will try it follow your tips

I hope that you can find the problem.  Otherwise, I will have to revert the commit.  It is more important that NuttX builds correctly on macOS than to have this feature.


SYNOPSIS
     sed [-Ealn] command [file ...]
     sed [-Ealn] [-e command] [-f command_file] [-i extension] [file ...]

make V=1
if [ ! -e /tmp/nuttx/.config -o ! -e /tmp/nuttx/Make.defs ]; then \
        echo "" ; \
        echo "Nuttx has not been configured:" ; \
        echo "  tools/configure.sh <target>" ; \
        echo "" ; \
        exit 1 ; \
    fi
sed -i '/CONFIG_GIT_/d' /tmp/nuttx/.version
sed: 1: "/tmp/nuttx/.version": extra characters at the end of n command

spudaneco

unread,
Sep 7, 2019, 12:44:24 AM9/7/19
to nu...@googlegroups.com
Thank you!  So the problem is indeed the 'sed -i' which works differently on GNU vs BSD based coreutils.  We will need to redesign the sed logic to be portable.  Thoughts, David?

The are a few other bash scripts under tools/ that have the same non-portable sed construct, but these are not on the critical build path.



Sent from Samsung tablet.

patacongo

unread,
Sep 7, 2019, 10:28:28 AM9/7/19
to NuttX
David,

I think I know a simple way to fix this.  Let me give it a try.

Greg

patacongo

unread,
Sep 7, 2019, 10:45:19 AM9/7/19
to NuttX

I think I know a simple way to fix this.  Let me give it a try.

Please try this:

commit d07666c85bbc54e620829ece4fd19e111d131b67
Author: Gregory Nutt <gn...@nuttx.org>
Date:   Sat Sep 7 08:44:16 2019 -0600

    tools/Makefile.unix:  Rethink creation of new .version file with GIT information.  Cannot use 'sed -i' in its current form because that does not work on macOS, FreeBSD, or NetBSD.

Lwazi

unread,
Sep 7, 2019, 11:37:21 AM9/7/19
to NuttX
You fixed it. Thanks.

Lwazi

Gregory Nutt

unread,
Sep 7, 2019, 12:10:10 PM9/7/19
to nu...@googlegroups.com

> You fixed it. Thanks.

Great to hear.  The existing logic used "sed -i" to remove the GIT HEAD
version info from the .version file, then a new script in tools/ to add
the new GIT HEAD version info.

There are two basic ways to solve this problem:

1. Fix the line deletion logic so that it does not depend on
incompatible coreutils.  For example you could replace the 'sed -i' with
'cat .version|sed -e" to a temporary file, then overwrite .version with
the temporary file.

2. Change how the .version file is updated altogether

I did #2.  Now the Makefile reads the .version file, then re-writes the
entire .version file on each build with the new GIT HEAD version info.

I hope it does not cause problems on other platforms and that it does
not 'leak' version information.

I have made a commitment to support NuttX on a wide variety of
platforms, most of which I do not even have.  That makes any change to
the build system risky and prone to breakage on some platform.



David Alessio

unread,
Sep 8, 2019, 3:41:27 AM9/8/19
to NuttX
Sorry for the delay, had a minor emergency to deal with.

I'd suggest we change 'sed -i' to 'sed -i.old'   That works with GNU sed and BSD sed.  Then decide to keep or delete "*.old" backup file.

There are two places in Makefile.unix that need this fix.

David Alessio

unread,
Sep 8, 2019, 4:39:40 PM9/8/19
to NuttX
Sorry, I was too late this time.
Reply all
Reply to author
Forward
0 new messages