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

1.4.1 fails building fel with gcc 6.2.1 on Fedora #74

Closed
nullr0ute opened this issue Oct 29, 2016 · 6 comments
Closed

1.4.1 fails building fel with gcc 6.2.1 on Fedora #74

nullr0ute opened this issue Oct 29, 2016 · 6 comments

Comments

@nullr0ute
Copy link

Lots of undefined errors

+ make -j4 'CFLAGS=-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic -Iinclude -D_POSIX_C_SOURCE=200112L -std=c99'
./autoversion.sh: line 9: git: command not found
Unable to determine current version (using "v1.4.1" as fallback)
cc -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic -Iinclude -D_POSIX_C_SOURCE=200112L -std=c99  -o sunxi-fexc fexc.c script.c script_uboot.c script_bin.c script_fex.c 
cc -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic -Iinclude -D_POSIX_C_SOURCE=200112L -std=c99  -o sunxi-bootinfo bootinfo.c 
cc -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic -Iinclude -D_POSIX_C_SOURCE=200112L -std=c99 `pkg-config --cflags libusb-1.0`  -o sunxi-fel fel.c progress.c  `pkg-config --libs libusb-1.0`
cc -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic -Iinclude -D_POSIX_C_SOURCE=200112L -std=c99 -c -o nand-part-main.o nand-part-main.c
fel.c: In function 'get_image_type':
fel.c:164:6: warning: implicit declaration of function 'be32toh' [-Wimplicit-function-declaration]
  if (be32toh(buf32[0]) != IH_MAGIC) /* signature mismatch */
      ^~~~~~~
fel.c: In function 'aw_send_usb_request':
fel.c:178:14: warning: implicit declaration of function 'htole16' [-Wimplicit-function-declaration]
   .request = htole16(type),
              ^~~~~~~
fel.c:179:13: warning: implicit declaration of function 'htole32' [-Wimplicit-function-declaration]
   .length = htole32(length),
             ^~~~~~~
fel.c: In function 'aw_fel_get_version':
fel.c:242:17: warning: implicit declaration of function 'le32toh' [-Wimplicit-function-declaration]
  buf->soc_id = (le32toh(buf->soc_id) >> 8) & 0xFFFF;
                 ^~~~~~~
fel.c:245:20: warning: implicit declaration of function 'le16toh' [-Wimplicit-function-declaration]
  buf->scratchpad = le16toh(buf->scratchpad);
                    ^~~~~~~
fel.c: In function 'aw_fel_write_and_execute_spl':
fel.c:1217:2: warning: implicit declaration of function 'usleep' [-Wimplicit-function-declaration]
  usleep(250000);
  ^~~~~~
cc -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic -Iinclude -D_POSIX_C_SOURCE=200112L -std=c99 -c -o nand-part-a10.o nand-part.c -D A10
nand-part.c: In function 'writembrs':
nand-part.c:240:2: warning: ignoring return value of 'read', declared with attribute warn_unused_result [-Wunused-result]
  read(0, &yn, 1);
  ^~~~~~~~~~~~~~~
nand-part.c:251:3: warning: ignoring return value of 'write', declared with attribute warn_unused_result [-Wunused-result]
   write(fd,mbr,MBR_SIZE);
   ^~~~~~~~~~~~~~~~~~~~~~
cc -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic -Iinclude -D_POSIX_C_SOURCE=200112L -std=c99 -c -o nand-part-a20.o nand-part.c -D A20
nand-part.c: In function 'writembrs':
nand-part.c:240:2: warning: ignoring return value of 'read', declared with attribute warn_unused_result [-Wunused-result]
  read(0, &yn, 1);
  ^~~~~~~~~~~~~~~
nand-part.c:251:3: warning: ignoring return value of 'write', declared with attribute warn_unused_result [-Wunused-result]
   write(fd,mbr,MBR_SIZE);
   ^~~~~~~~~~~~~~~~~~~~~~
cc  -o sunxi-nand-part nand-part-main.o nand-part-a10.o nand-part-a20.o 
ln -nsf sunxi-fexc bin2fex
ln -nsf sunxi-fexc fex2bin
/tmp/ccgEW415.o: In function `get_image_type':
/builddir/build/BUILD/sunxi-tools-1.4.1/fel.c:164: undefined reference to `be32toh'
/tmp/ccgEW415.o: In function `aw_send_usb_request':
/builddir/build/BUILD/sunxi-tools-1.4.1/fel.c:179: undefined reference to `htole32'
/builddir/build/BUILD/sunxi-tools-1.4.1/fel.c:180: undefined reference to `htole32'
/builddir/build/BUILD/sunxi-tools-1.4.1/fel.c:178: undefined reference to `htole16'
/tmp/ccgEW415.o: In function `aw_send_fel_request':
/builddir/build/BUILD/sunxi-tools-1.4.1/fel.c:223: undefined reference to `htole32'
/builddir/build/BUILD/sunxi-tools-1.4.1/fel.c:224: undefined reference to `htole32'
/builddir/build/BUILD/sunxi-tools-1.4.1/fel.c:225: undefined reference to `htole32'
/tmp/ccgEW415.o: In function `aw_fel_get_version':
/builddir/build/BUILD/sunxi-tools-1.4.1/fel.c:242: undefined reference to `le32toh'
/builddir/build/BUILD/sunxi-tools-1.4.1/fel.c:243: undefined reference to `le32toh'
/builddir/build/BUILD/sunxi-tools-1.4.1/fel.c:244: undefined reference to `le32toh'
/builddir/build/BUILD/sunxi-tools-1.4.1/fel.c:245: undefined reference to `le16toh'
/builddir/build/BUILD/sunxi-tools-1.4.1/fel.c:246: undefined reference to `le32toh'
/builddir/build/BUILD/sunxi-tools-1.4.1/fel.c:247: undefined reference to `le32toh'
/tmp/ccgEW415.o: In function `aw_fel_write_uboot_image':
/builddir/build/BUILD/sunxi-tools-1.4.1/fel.c:1267: undefined reference to `be32toh'
/builddir/build/BUILD/sunxi-tools-1.4.1/fel.c:1268: undefined reference to `be32toh'
/tmp/ccgEW415.o: In function `aw_fel_writel_n':
/builddir/build/BUILD/sunxi-tools-1.4.1/fel.c:763: undefined reference to `htole32'
/builddir/build/BUILD/sunxi-tools-1.4.1/fel.c:764: undefined reference to `htole32'
/builddir/build/BUILD/sunxi-tools-1.4.1/fel.c:765: 
RPM build errors:
undefined reference to `htole32'
/builddir/build/BUILD/sunxi-tools-1.4.1/fel.c:766: undefined reference to `htole32'
/builddir/build/BUILD/sunxi-tools-1.4.1/fel.c:767: undefined reference to `htole32'
/tmp/ccgEW415.o:/builddir/build/BUILD/sunxi-tools-1.4.1/fel.c:768: more undefined references to `htole32' follow
/tmp/ccgEW415.o: In function `aw_read_arm_cp_reg':
/builddir/build/BUILD/sunxi-tools-1.4.1/fel.c:692: undefined reference to `le32toh'
/tmp/ccgEW415.o: In function `aw_write_arm_cp_reg':
/builddir/build/BUILD/sunxi-tools-1.4.1/fel.c:706: undefined reference to `htole32'
/builddir/build/BUILD/sunxi-tools-1.4.1/fel.c:707: undefined reference to `htole32'
/builddir/build/BUILD/sunxi-tools-1.4.1/fel.c:708: undefined reference to `htole32'
/builddir/build/BUILD/sunxi-tools-1.4.1/fel.c:709: undefined reference to `htole32'
/builddir/build/BUILD/sunxi-tools-1.4.1/fel.c:710: undefined reference to `htole32'
/tmp/ccgEW415.o:/builddir/build/BUILD/sunxi-tools-1.4.1/fel.c:711: more undefined references to `htole32' follow
/tmp/ccgEW415.o: In function `aw_fel_readl_n':
/builddir/build/BUILD/sunxi-tools-1.4.1/fel.c:743: undefined reference to `le32toh'
/tmp/ccgEW415.o: In function `aw_enable_l2_cache':
/builddir/build/BUILD/sunxi-tools-1.4.1/fel.c:814: undefined reference to `htole32'
/builddir/build/BUILD/sunxi-tools-1.4.1/fel.c:815: undefined reference to `htole32'
/builddir/build/BUILD/sunxi-tools-1.4.1/fel.c:816: undefined reference to `htole32'
/builddir/build/BUILD/sunxi-tools-1.4.1/fel.c:817: undefined reference to `htole32'
/tmp/ccgEW415.o: In function `aw_get_stackinfo':
/builddir/build/BUILD/sunxi-tools-1.4.1/fel.c:843: undefined reference to `htole32'
/tmp/ccgEW415.o:/builddir/build/BUILD/sunxi-tools-1.4.1/fel.c:844: more undefined references to `htole32' follow
/tmp/ccgEW415.o: In function `aw_get_stackinfo':
/builddir/build/BUILD/sunxi-tools-1.4.1/fel.c:858: undefined reference to `le32toh'
/builddir/build/BUILD/sunxi-tools-1.4.1/fel.c:859: undefined reference to `le32toh'
/tmp/ccgEW415.o: In function `aw_backup_and_disable_mmu':
/builddir/build/BUILD/sunxi-tools-1.4.1/fel.c:942: undefined reference to `htole32'
/builddir/build/BUILD/sunxi-tools-1.4.1/fel.c:943: undefined reference to `htole32'
/builddir/build/BUILD/sunxi-tools-1.4.1/fel.c:944: undefined reference to `htole32'
/builddir/build/BUILD/sunxi-tools-1.4.1/fel.c:945: undefined reference to `htole32'
/builddir/build/BUILD/sunxi-tools-1.4.1/fel.c:946: undefined reference to `htole32'
/tmp/ccgEW415.o:/builddir/build/BUILD/sunxi-tools-1.4.1/fel.c:948: more undefined references to `htole32' follow
/tmp/ccgEW415.o: In function `aw_backup_and_disable_mmu':
/builddir/build/BUILD/sunxi-tools-1.4.1/fel.c:996: undefined reference to `le32toh'
/tmp/ccgEW415.o: In function `aw_restore_and_enable_mmu':
/builddir/build/BUILD/sunxi-tools-1.4.1/fel.c:1027: undefined reference to `htole32'
/builddir/build/BUILD/sunxi-tools-1.4.1/fel.c:1028: undefined reference to `htole32'
/builddir/build/BUILD/sunxi-tools-1.4.1/fel.c:1029: undefined reference to `htole32'
/builddir/build/BUILD/sunxi-tools-1.4.1/fel.c:1030: undefined reference to `htole32'
/builddir/build/BUILD/sunxi-tools-1.4.1/fel.c:1031: undefined reference to `htole32'
/tmp/ccgEW415.o:/builddir/build/BUILD/sunxi-tools-1.4.1/fel.c:1032: more undefined references to `htole32' follow
/tmp/ccgEW415.o: In function `aw_fel_write_and_execute_spl':
/builddir/build/BUILD/sunxi-tools-1.4.1/fel.c:1102: undefined reference to `le32toh'
/builddir/build/BUILD/sunxi-tools-1.4.1/fel.c:1103: undefined reference to `le32toh'
/builddir/build/BUILD/sunxi-tools-1.4.1/fel.c:1112: undefined reference to `le32toh'
/builddir/build/BUILD/sunxi-tools-1.4.1/fel.c:1207: undefined reference to `htole32'
/tmp/ccgEW415.o: In function `pass_fel_information':
/builddir/build/BUILD/sunxi-tools-1.4.1/fel.c:1367: undefined reference to `htole32'
/builddir/build/BUILD/sunxi-tools-1.4.1/fel.c:1368: undefined reference to `htole32'
/tmp/ccgEW415.o: In function `aw_rmr_request':
/builddir/build/BUILD/sunxi-tools-1.4.1/fel.c:1436: undefined reference to `htole32'
/builddir/build/BUILD/sunxi-tools-1.4.1/fel.c:1437: undefined reference to `htole32'
/tmp/ccgEW415.o:/builddir/build/BUILD/sunxi-tools-1.4.1/fel.c:1438: more undefined references to `htole32' follow
collect2: error: ld returned 1 exit status
make: *** [Makefile:119: sunxi-fel] Error 1
@n1tehawk
Copy link
Collaborator

n1tehawk commented Oct 29, 2016

You're overriding CFLAGS, killing the DEFINES that would normally get passed from our Makefile, e.g. https://github.com/linux-sunxi/sunxi-tools/blob/v1.4.1/Makefile#L25-L27. The absence of -D_BSD_SOURCE then cripples portable_endian.h.

If you wish to pass additional CFLAGS, you should preferably use EXTRA_CFLAGS instead.

Regards, NiteHawk

@ssvb
Copy link
Contributor

ssvb commented Oct 29, 2016

I would say that we should use CFLAGS for passing additional options (instead of inventing EXTRA_CFLAGS), because it's a common practice used by all build systems. Or at least by autotools and CMake.

It is generally a good idea to follow the principle of least astonishment :)

@n1tehawk
Copy link
Collaborator

n1tehawk commented Oct 29, 2016

How do we ensure we get our required flags in? Add whatever we need on top of existing CFLAGS - e.g. CFLAGS += -D_BSD_SOURCE -, or pass them independently in the Makefile rules?

Additionally: Who's supposed to "win" in case of conflicts, e.g. -g vs. -s, -O0 vs. -O2 etc. ?

@ssvb
Copy link
Contributor

ssvb commented Oct 29, 2016

Maybe introduce a new DEFAULT_CFLAGS variable in the makefile? Then append the user supplied CFLAGS variable to it. The user's CFLAGS should have the highest priority and the power to override the default options (for example, providing -O3 option to override the default -O2). Again, this is the way how the other build systems work.

@n1tehawk
Copy link
Collaborator

Yes, that seems reasonable.

@ssvb
Copy link
Contributor

ssvb commented Oct 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

No branches or pull requests

3 participants