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

Build error OS: FreeBSD 9.x,10.x/gcc v4.2.1 AT: libr/anal/p/anal_avr.c ERR: unknown field 'consts' at 'cpu_models[]' #6268

Closed
unixfreaxjp opened this issue Nov 29, 2016 · 21 comments

Comments

@unixfreaxjp
Copy link

unixfreaxjp commented Nov 29, 2016

This is the copy of wrongly posted issue at radareorg/radare#3

  • r2 version:
heads/master-0-gffd8ecd
  • Build environment: FreeBSD i386
Final report:
 - PREFIX = /usr
 - HAVE_LIB_GMP = 0
 - HAVE_OPENSSL = 0
 - USE_CAPSTONE = 0
 - HAVE_FORK = 1
 - VERSION = 1.1.0-git
 - USE_LIB_ZIP = 0
 - USE_LIB_MAGIC = 0
 - DEBUGGER = 1
 - CC = gcc
 - USERCC = gcc
 - USEROSTYPE = bsd
 - LIBVERSION = 1.1.0-git
 - BUILD = i386-unknown-freebsd
 - HOST = i386-unknown-freebsd
 - TARGET = i386-unknown-freebsd

compiler info:

]$ gcc --version
gcc (GCC) 4.2.1 20070831 patched [FreeBSD]
Copyright (C) 2007 Free Software Foundation, Inc.
  • Error occurred at:
 :
CC anal_avr.c
/libr/..//libr/anal/p/anal_avr.c:112: error: unknown field 'consts' specified in initializer
/libr/..//libr/anal/p/anal_avr.c:120: error: unknown field 'consts' specified in initializer
gmake[3]: *** [/TEST/radare/radare2/libr/../global.mk:42: /TEST/radare/radare2/libr/..//libr/anal/p/anal_avr.o] Error 1
gmake[2]: *** [Makefile:83: anal] Error 2
gmake[1]: *** [Makefile:31: all] Error 2
gmake: *** [Makefile:51: all] Error 2
  :
radare2 1.1.0-git 13124 @ linux-x86-32 git.1.0.2-173-g83d002c
commit: 83d002cee5214675d67d5b48105a7278a81543c1 build: 2016-11-29
  • The point of problem:

The usage of (undeclared/undefined) .consts for FreeBSD is not compatible in /libr/anal/p/anal_avr.c this function at CPU_MODEL cpu_models[], xref: (1) https://github.com/radare/radare2/blob/master/libr/anal/p/anal_avr.c#L112 and (2) https://github.com/radare/radare2/blob/master/libr/anal/p/anal_avr.c#L120
problem: **Anonymized Union**
Code:

CPU_MODEL cpu_models[] = {
	{
		.model = "ATmega8", .pc = 13,
		.consts = {  // <=====================
			cpu_reg_common,
			cpu_memsize_common,
			cpu_pagesize_32,
			NULL
		}
	},
	{ .model = "ATmega640",   .pc = 15,
		.consts = { // <=====================
			cpu_reg_common,
			cpu_memsize_m640_m1280m_m1281_m2560_m2561,
			cpu_pagesize_256,
			NULL
		},
	},
	{ .model = "ATmega1280",  .pc = 16, .inherit = "ATmega640" },
	{ .model = "ATmega1281",  .pc = 16, .inherit = "ATmega640" },
	{ .model = "ATmega2560",  .pc = 17, .inherit = "ATmega640" },
	{ .model = "ATmega2561",  .pc = 17, .inherit = "ATmega640" },
	{ .model = "ATmega88",    .pc = 8,  .inherit = "ATmega8" },
	{ .model = "unknown_avr", .pc = 8,  .inherit = "ATmega8" } // default AVR - ATmega8 forever!
//	CPU_MODEL_DECL ("ATmega168",   13, 512, 512),
};

@radare @XVilka @crowell @jvoisin @Maijin

@radare
Copy link
Collaborator

radare commented Nov 29, 2016

wat? build fine here

@unixfreaxjp
Copy link
Author

unixfreaxjp commented Nov 29, 2016

Maijin commented 5 minutes ago
@unixfreaxjp next time please open issue on https://github.com/radare/radare2 repo not "radare"

Done.

@radare commented 7 minutes ago
cant reproduce

It was occured in x32/gcc 4.2.1 20070831 patched [FreeBSD]
Let's see if this occured in x86-64 & amd64 FreeeBSD too (hold on..)

@radare
Copy link
Collaborator

radare commented Nov 29, 2016

i have tested on freebsd-amd64, linux-arm and osx-x86-64, no issues at all

@XVilka
Copy link
Contributor

XVilka commented Nov 29, 2016

What compiler do you use?

@unixfreaxjp
Copy link
Author

@XVilka commented 2 minutes ago
What compiler do you use?

$ gcc --version

gcc (GCC) 4.2.1 20070831 patched [FreeBSD]
Copyright (C) 2007 Free Software Foundation, Inc.

@XVilka
Copy link
Contributor

XVilka commented Nov 29, 2016

It's this bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=10676

@XVilka XVilka closed this as completed Nov 29, 2016
@XVilka
Copy link
Contributor

XVilka commented Nov 29, 2016

@unixfreaxjp please try now

@unixfreaxjp
Copy link
Author

unixfreaxjp commented Nov 29, 2016

@radare commented 14 minutes ago
i have tested on freebsd-amd64, linux-arm and osx-x86-64, no issues at all

This, occurred as well in amd64 in two machines different FreeBSD version (9.x and 10.x)
One quick grabbed error log: https://github.com/unixfreaxjp/dev/blob/master/r2freebsdx64-4.md

@Maijin
Copy link
Contributor

Maijin commented Nov 29, 2016

@unixfreaxjp please try now

@unixfreaxjp
Copy link
Author

unixfreaxjp commented Nov 29, 2016

@XVilka commented 2 minutes ago
@unixfreaxjp please try now

Retrying now. @Maijin

@Maijin Maijin reopened this Nov 29, 2016
@XVilka
Copy link
Contributor

XVilka commented Nov 29, 2016

The solution is to eliminate anonymous union.

@unixfreaxjp
Copy link
Author

unixfreaxjp commented Nov 29, 2016

@XVilka @Maijin @radare
build error is persisted. In union initial part.
It was well before in last week compilation.. same cc (GCC) 4.2.1 20070831 patched [FreeBSD]
This is gcc compatibility problem..

x32 log:

Tue Nov 29 20:33:56 JST 2016
heads/master-0-g74bb05a
 :
CC anal_avr.c
/TEST/radare/radare2/libr/..//libr/anal/p/anal_avr.c:112: warning: braces around scalar initializer
/TEST/radare/radare2/libr/..//libr/anal/p/anal_avr.c:112: warning: (near initialization for 'cpu_models[0].inherit')
/TEST/radare/radare2/libr/..//libr/anal/p/anal_avr.c:113: error: field name not in record or union initializer
/TEST/radare/radare2/libr/..//libr/anal/p/anal_avr.c:113: error: (near initialization for 'cpu_models[0].inherit')
/TEST/radare/radare2/libr/..//libr/anal/p/anal_avr.c:113: warning: braces around scalar initializer
/TEST/radare/radare2/libr/..//libr/anal/p/anal_avr.c:113: warning: (near initialization for 'cpu_models[0].inherit')
/TEST/radare/radare2/libr/..//libr/anal/p/anal_avr.c:114: warning: initialization from incompatible pointer type
/TEST/radare/radare2/libr/..//libr/anal/p/anal_avr.c:115: warning: excess elements in scalar initializer
/TEST/radare/radare2/libr/..//libr/anal/p/anal_avr.c:115: warning: (near initialization for 'cpu_models[0].inherit')
/TEST/radare/radare2/libr/..//libr/anal/p/anal_avr.c:116: warning: excess elements in scalar initializer
/TEST/radare/radare2/libr/..//libr/anal/p/anal_avr.c:116: warning: (near initialization for 'cpu_models[0].inherit')
/TEST/radare/radare2/libr/..//libr/anal/p/anal_avr.c:118: warning: excess elements in scalar initializer
/TEST/radare/radare2/libr/..//libr/anal/p/anal_avr.c:118: warning: (near initialization for 'cpu_models[0].inherit')
/TEST/radare/radare2/libr/..//libr/anal/p/anal_avr.c:122: warning: braces around scalar initializer
/TEST/radare/radare2/libr/..//libr/anal/p/anal_avr.c:122: warning: (near initialization for 'cpu_models[1].inherit')
/TEST/radare/radare2/libr/..//libr/anal/p/anal_avr.c:123: error: field name not in record or union initializer
/TEST/radare/radare2/libr/..//libr/anal/p/anal_avr.c:123: error: (near initialization for 'cpu_models[1].inherit')
/TEST/radare/radare2/libr/..//libr/anal/p/anal_avr.c:123: warning: braces around scalar initializer
/TEST/radare/radare2/libr/..//libr/anal/p/anal_avr.c:123: warning: (near initialization for 'cpu_models[1].inherit')
/TEST/radare/radare2/libr/..//libr/anal/p/anal_avr.c:124: warning: initialization from incompatible pointer type
/TEST/radare/radare2/libr/..//libr/anal/p/anal_avr.c:125: warning: excess elements in scalar initializer
/TEST/radare/radare2/libr/..//libr/anal/p/anal_avr.c:125: warning: (near initialization for 'cpu_models[1].inherit')
/TEST/radare/radare2/libr/..//libr/anal/p/anal_avr.c:126: warning: excess elements in scalar initializer
/TEST/radare/radare2/libr/..//libr/anal/p/anal_avr.c:126: warning: (near initialization for 'cpu_models[1].inherit')
/TEST/radare/radare2/libr/..//libr/anal/p/anal_avr.c:128: warning: excess elements in scalar initializer
/TEST/radare/radare2/libr/..//libr/anal/p/anal_avr.c:128: warning: (near initialization for 'cpu_models[1].inherit')
gmake[3]: *** [/TEST/radare/radare2/libr/../global.mk:42: /TEST/radare/radare2/libr/..//libr/anal/p/anal_avr.o] Error 1
gmake[3]: *** Waiting for unfinished jobs....
gmake[2]: *** [Makefile:83: anal] Error 2
gmake[2]: *** Waiting for unfinished jobs....
/TEST/radare/radare2/libr/bin/p
SHLR=/TEST/radare/radare2/libr/..//libr/../shlr
gmake[1]: *** [Makefile:31: all] Error 2
gmake: *** [Makefile:51: all] Error 2

@unixfreaxjp
Copy link
Author

@XVilka @Maijin @radare

all of our dev systems is using gcc 4.2.1,
what should I do to make this work?

@XVilka
Copy link
Contributor

XVilka commented Nov 29, 2016

Someone will do the fix today, just not right now.

@unixfreaxjp
Copy link
Author

unixfreaxjp commented Nov 29, 2016

I will urgently plan upgrade gcc on many of the bsd analysis clusters then. We use servers to analyze UNIX bad stuff, not client.. upgrading gcc will upgrade ton of dev stuff too..
Taking off the urgent flag. Will re-open the issue if still persist after using recent gcc.
Thank's for the answers, appreciated. If any solution for this, please help.
One urgent analysis is in progress now, will use version RELEASE-0.10.5(PRECON) for quick workup, built well:

radare2 0.10.5 9999999 @ freebsd-x86-32 git.0.10.5
commit: HEAD build: 2016-11-29

Cheers.

@unixfreaxjp unixfreaxjp changed the title URGENCY: High - Build error OS: FreeBSD AT: libr/anal/p/anal_avr.c ERR: unknown field 'consts' at 'cpu_models[]' Build error OS: FreeBSD 9.x,10.x/gcc v4.2.1 AT: libr/anal/p/anal_avr.c ERR: unknown field 'consts' at 'cpu_models[]' Nov 29, 2016
@unixfreaxjp
Copy link
Author

unixfreaxjp commented Dec 1, 2016

@radare @XVilka @Maijin @unixfreaxjp @killabytenow
I still wonder since when gcc 4.2.1. is becoming incompatible, since I swear it was working few weeks back. Below is the report I run on several radare2 built for test under gcc 4.2.1 :

radare2-1.0 aka "Finally" works, proof:

$ date&&r2 -v
Thu Dec  1 14:37:04 JST 2016
radare2 1.0 9999999 @ freebsd-x86-32 git.1.0
commit: HEAD build: 2016-12-01

radare2 version 1.0.2 is also proven works / built fine:

$ date&&r2 -v
Thu Dec  1 14:44:38 JST 2016
radare2 1.0.2 9999999 @ freebsd-x86-32 git.1.0.2
commit: HEAD build: 2016-12-01

##The problem is sourced in here:##

There must be a code change in development after 1.0.2 RELEASE (November the 10th, 2016) that affects this good gcc compatibility quality that radare2 had before, I was just tracing it now, to find this commit code (on Nov 19, 2016 ), the code is here: 9d6bbf9 by @killabytenow is the source.

A policy in the development need to be decided on the anonymous union usage on the radare2 code. I leave this matter to the development tops to decide.

@radare
Copy link
Collaborator

radare commented Dec 1, 2016

yeah im not really a fan of anonymous unions, wondering if there's any gcc flag to enforce this

@radare radare reopened this Dec 1, 2016
@radare
Copy link
Collaborator

radare commented Dec 1, 2016

why this issue is closed if its not fixed?

@unixfreaxjp
Copy link
Author

unixfreaxjp commented Dec 1, 2016

why this issue is closed if its not fixed?

Because I know that you are busy.. and people can use workaround to use 1.0.2,

wondering if there's any bcc flag to enforce this

Believe me, I already on seeking that too. But there is no easy configure option that can be used for forcing this.

I agree for the @XVilka suggestion for the recoding without anonymous unions , or, we are accepting the limitation on used gcc version. It is the decision that you should make due to product's compatibility, quality, roadmaps are related.

@radare radare closed this as completed in 13c15cb Dec 1, 2016
@unixfreaxjp
Copy link
Author

unixfreaxjp commented Dec 1, 2016

I tested 13c15cb (and to de-anonymize the AVR union ) on x86-32 and x86-64

32bit:

$ date&&r2 -v&&uname
Thu Dec  1 23:21:57 JST 2016
radare2 1.1.0-git 13133 @ freebsd-x86-32 git.1.0.2-189-ge4b5f0f
commit: e4b5f0f32b0f6bff4f3537bd2800d5801eb5e513 build: 2016-12-01
FreeBSD

64bit:

$ pwd&&date&&r2 -v&&uname
/TEST/radare2
Thu Dec  1 23:29:40 JST 2016
radare2 1.1.0-git 13133 @ freebsd-x86-64 git.1.0.2-189-ge4b5f0f
commit: e4b5f0f32b0f6bff4f3537bd2800d5801eb5e513 build: 2016-12-01
FreeBSD

Thank you now it works just fine :)

@radare
Copy link
Collaborator

radare commented Dec 1, 2016 via email

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

4 participants