Skip to content

Fix build for DragonFly BSD#83

Closed
tuxillo wants to merge 1 commit intolinux-sunxi:masterfrom
tuxillo:patch-1
Closed

Fix build for DragonFly BSD#83
tuxillo wants to merge 1 commit intolinux-sunxi:masterfrom
tuxillo:patch-1

Conversation

@tuxillo
Copy link
Copy Markdown

@tuxillo tuxillo commented Nov 20, 2016

No description provided.

@ssvb
Copy link
Copy Markdown
Contributor

ssvb commented Nov 20, 2016

Could you please add the build error console output to the commit message to make this a perfect patch? BTW, looks like the fix is very similar to 043761b

@ssvb
Copy link
Copy Markdown
Contributor

ssvb commented Nov 20, 2016

@n1tehawk already attempted to contact @panzi in the https://gist.github.com/panzi/6856583 gist about this. Also I see that the only difference in that problematic ifdef block are some extra defines. Could it be that they are only needed on some versions of NetBSD and DragonFly and caouse build problems on the others? The information about the DragonFly BSD version (or rather the version of its C library?) would be welcome in the commit message too.

@n1tehawk
Copy link
Copy Markdown
Collaborator

AFAICT DragonFly is a FreeBSD derivate, so it seems natural that this change follows the 043761b one.

When you amend your commit message, please add a "Signed-by:" (commit -s).

Regards, NiteHawk

@tuxillo
Copy link
Copy Markdown
Author

tuxillo commented Nov 20, 2016

Hi,

This is the build error:

$ gmake
Setting version information: v1.4.1-27-g8e53d2b

cc -std=c99 -Wall -Wextra -Wno-unused-result -D_POSIX_C_SOURCE=200112L -D_BSD_SOURCE -D_DEFAULT_SOURCE -Iinclude/ -o sunxi-fexc fexc.c script.c script_uboot.c script_bin.c script_fex.c
cc -std=c99 -Wall -Wextra -Wno-unused-result -D_POSIX_C_SOURCE=200112L -D_BSD_SOURCE -D_DEFAULT_SOURCE -Iinclude/ -o sunxi-bootinfo bootinfo.c
cc -std=c99 -Wall -Wextra -Wno-unused-result -D_POSIX_C_SOURCE=200112L -D_BSD_SOURCE -D_DEFAULT_SOURCE -Iinclude/ pkg-config --cflags libusb-1.0 -o sunxi-fel fel.c progress.c soc_info.c pkg-config --libs libusb-1.0
In file included from fel.c:19:0:
include/portable_endian.h:52:0: warning: "be16toh" redefined

define be16toh(x) betoh16(x)

^
In file included from include/portable_endian.h:50:0,
from fel.c:19:
/usr/include/sys/endian.h:58:0: note: this is the location of the previous definition
#define be16toh(x) bswap16((x))
^
In file included from fel.c:19:0:
include/portable_endian.h:53:0: warning: "le16toh" redefined

define le16toh(x) letoh16(x)

^
In file included from include/portable_endian.h:50:0,
from fel.c:19:
/usr/include/sys/endian.h:61:0: note: this is the location of the previous definition
#define le16toh(x) ((uint16_t)(x))
^
In file included from fel.c:19:0:
include/portable_endian.h:55:0: warning: "be32toh" redefined

define be32toh(x) betoh32(x)

^
In file included from include/portable_endian.h:50:0,
from fel.c:19:
/usr/include/sys/endian.h:59:0: note: this is the location of the previous definition
#define be32toh(x) bswap32((x))
^
In file included from fel.c:19:0:
include/portable_endian.h:56:0: warning: "le32toh" redefined

define le32toh(x) letoh32(x)

^
In file included from include/portable_endian.h:50:0,
from fel.c:19:
/usr/include/sys/endian.h:62:0: note: this is the location of the previous definition
#define le32toh(x) ((uint32_t)(x))
^
In file included from fel.c:19:0:
include/portable_endian.h:58:0: warning: "be64toh" redefined

define be64toh(x) betoh64(x)

^
In file included from include/portable_endian.h:50:0,
from fel.c:19:
/usr/include/sys/endian.h:60:0: note: this is the location of the previous definition
#define be64toh(x) bswap64((x))
^
In file included from fel.c:19:0:
include/portable_endian.h:59:0: warning: "le64toh" redefined

define le64toh(x) letoh64(x)

^
In file included from include/portable_endian.h:50:0,
from fel.c:19:
/usr/include/sys/endian.h:63:0: note: this is the location of the previous definition
#define le64toh(x) ((uint64_t)(x))
^
In file included from fel.c:19:0:
fel.c: In function 'get_image_type':
include/portable_endian.h:55:21: warning: implicit declaration of function 'betoh32' [-Wimplicit-function-declaration]

define be32toh(x) betoh32(x)

                 ^

fel.c:165:6: note: in expansion of macro 'be32toh'
if (be32toh(buf32[0]) != IH_MAGIC) /* signature mismatch _/
^
fel.c: In function 'aw_fel_get_version':
include/portable_endian.h:56:21: warning: implicit declaration of function 'letoh32' [-Wimplicit-function-declaration]

define le32toh(x) letoh32(x)

                 ^

fel.c:243:17: note: in expansion of macro 'le32toh'
buf->soc_id = (le32toh(buf->soc_id) >> 8) & 0xFFFF;
^
include/portable_endian.h:53:21: warning: implicit declaration of function 'letoh16' [-Wimplicit-function-declaration]

define le16toh(x) letoh16(x)

                 ^

fel.c:246:20: note: in expansion of macro 'le16toh'
buf->scratchpad = le16toh(buf->scratchpad);
^
fel.c: In function 'aw_fel_write_and_execute_spl':
fel.c:1061:2: warning: implicit declaration of function 'usleep' [-Wimplicit-function-declaration]
usleep(250000);
^
progress.c: In function 'gettime':
progress.c:27:2: warning: implicit declaration of function 'gettimeofday' [-Wimplicit-function-declaration]
gettimeofday(&tv, NULL);
^
/tmp//ccTl0MaP.o:fel.c:function get_image_type: error: undefined reference to 'betoh32'
/tmp//ccTl0MaP.o:fel.c:function aw_fel_get_version: error: undefined reference to 'letoh32'
/tmp//ccTl0MaP.o:fel.c:function aw_fel_get_version: error: undefined reference to 'letoh32'
/tmp//ccTl0MaP.o:fel.c:function aw_fel_get_version: error: undefined reference to 'letoh32'
/tmp//ccTl0MaP.o:fel.c:function aw_fel_get_version: error: undefined reference to 'letoh16'
/tmp//ccTl0MaP.o:fel.c:function aw_fel_get_version: error: undefined reference to 'letoh32'
/tmp//ccTl0MaP.o:fel.c:function aw_fel_write_uboot_image: error: undefined reference to 'betoh32'
/tmp//ccTl0MaP.o:fel.c:function aw_fel_write_uboot_image: error: undefined reference to 'betoh32'
collect2: error: ld returned 1 exit status
gmake: *_* [Makefile:128: sunxi-fel] Error 1

Let me check this further.

Best regards,
Antonio Huete

@ssvb
Copy link
Copy Markdown
Contributor

ssvb commented Nov 20, 2016

Thanks! Just condense this error log (keep only the essential part) and add your Signed-off-by tag to the commit message (via "git commit --amend"). Then force-push the updated commit to the branch used for your merge request and we are done with it.

@n1tehawk
Copy link
Copy Markdown
Collaborator

n1tehawk commented Nov 21, 2016

I'm suspecting more and more that older *BSDs did not have those names in their endian.h, which is probably why those additional #defines were introduced. The functions don't seem to be part of the POSIX standard, but nevertheless have found widespread use. It looks like many BSD derivates have also adopted them.

It's well possible that we'll see the issue come up even on NetBSD - judging from https://ftp.netbsd.org/pub/NetBSD/NetBSD-current/src/sys/sys/endian.h we'd be redefining those macros there too.

Maybe we should test / safeguard the #defines in question with #ifndefs (after including sys/endian.h) instead, so they'd only get used if the symbols don't already exist?

[EDIT] Further information is available in the endian(3) man page (section "Conforming to"):

These functions are nonstandard. Similar functions are present on the BSDs, where the required header file is <sys/endian.h> instead of <endian.h>. Unfortunately, NetBSD, FreeBSD, and glibc haven't followed the original OpenBSD naming convention for these functions, whereby the nn component always appears at the end of the function name (thus, for example, in NetBSD, FreeBSD, and glibc, the equivalent of OpenBSDs betoh32 is be32toh).

It looks like this is 'historic' information that might no longer apply to more recent *BSD versions.

n1tehawk added a commit to n1tehawk/sunxi-tools that referenced this pull request Nov 22, 2016
See pull requests linux-sunxi#59 and linux-sunxi#83.

It looks like various BSD derivates have adopted the more common naming
conventions for the endian conversion macros, which means that we would
attempt to redefine them without need (potentially even to 'historic'
names that no longer exist).

Try to avoid this by properly checking for existing functions first.

Signed-off-by: Bernhard Nortmann <bernhard.nortmann@web.de>
@n1tehawk n1tehawk mentioned this pull request Nov 25, 2016
@evadot
Copy link
Copy Markdown
Contributor

evadot commented Nov 25, 2016

Haven't test the patch on FreeBSD but I don't see why it wouldn't work.

@tuxillo
Copy link
Copy Markdown
Author

tuxillo commented Nov 26, 2016

Hi,

Will try it over the weekend and report here.

Cheers,
Antonio Huete

Copy link
Copy Markdown
Contributor

@evadot evadot left a comment

Choose a reason for hiding this comment

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

Just tested on FreeBSD, no problem for me.

n1tehawk added a commit to n1tehawk/sunxi-tools that referenced this pull request Nov 28, 2016
See pull requests linux-sunxi#59 and linux-sunxi#83.

It looks like various BSD derivates have adopted the more common naming
conventions for the endian conversion macros, which means that we would
attempt to redefine them without need (potentially even to 'historic'
names that no longer exist).

Try to avoid this by properly checking for existing functions first.

Signed-off-by: Bernhard Nortmann <bernhard.nortmann@web.de>
n1tehawk added a commit that referenced this pull request Nov 29, 2016
See pull requests #59 and #83.

It looks like various BSD derivates have adopted the more common naming
conventions for the endian conversion macros, which means that we would
attempt to redefine them without need (potentially even to 'historic'
names that no longer exist).

Try to avoid this by properly checking for existing functions first.

Signed-off-by: Bernhard Nortmann <bernhard.nortmann@web.de>
@n1tehawk
Copy link
Copy Markdown
Collaborator

Should be addressed by merging 384ff64 - closing this now.

@n1tehawk n1tehawk closed this Nov 29, 2016
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.

4 participants