Discussion:
[OpenOCD-devel] [openocd:tickets] #151 OpenOCD fails to build on macOS due to redefined macro
Girts F
2017-04-23 22:07:02 UTC
Permalink
---

** [tickets:#151] OpenOCD fails to build on macOS due to redefined macro**

**Status:** new
**Milestone:** 0.9.0
**Created:** Sun Apr 23, 2017 10:07 PM UTC by Girts F
**Last Updated:** Sun Apr 23, 2017 10:07 PM UTC
**Owner:** nobody


~~~
libtool: compile: gcc -DHAVE_CONFIG_H -I. -I./src -I./src -I./src/helper -DPKGDATADIR=\"/usr/local/share/openocd\" -DBINDIR=\"/usr/local/bin\" -I./jimtcl -I./jimtcl -Wall -Wstrict-prototypes -Wformat-security -Wshadow -Wextra -Wno-unused-parameter -Wbad-function-cast -Wcast-align -Wredundant-decls -Werror -g -O2 -MT src/target/openrisc/or1k_tap_xilinx_bscan.lo -MD -MP -MF src/target/openrisc/.deps/or1k_tap_xilinx_bscan.Tpo -c src/target/openrisc/or1k_tap_xilinx_bscan.c -o src/target/openrisc/or1k_tap_xilinx_bscan.o
src/target/aarch64.c:33:9: error: '__unused' macro redefined [-Werror,-Wmacro-redefined]
#define __unused __attribute((unused))
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/sys/cdefs.h:161:9: note: previous
definition is here
#define __unused __attribute__((unused))
^
1 error generated.
/bin/sh ./libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I./src -I./src -I./src/helper -DPKGDATADIR=\"/usr/local/share/openocd\" -DBINDIR=\"/usr/local/bin\" -I./jimtcl -I./jimtcl -Wall -Wstrict-prototypes -Wformat-security -Wshadow -Wextra -Wno-unused-parameter -Wbad-function-cast -Wcast-align -Wredundant-decls -Werror -g -O2 -MT src/server/src_server_libserver_la-telnet_server.lo -MD -MP -MF src/server/.deps/src_server_libserver_la-telnet_server.Tpo -c -o src/server/src_server_libserver_la-telnet_server.lo `test -f 'src/server/telnet_server.c' || echo './'`src/server/telnet_server.c
make[2]: *** [src/target/aarch64.lo] Error 1
~~~
This is on macOS 10.12.4 at commit 8addd9503eeb7704907d2340378d1200e3bbb99c.

CC version:
~~~
$ gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/c++/4.2.1
Apple LLVM version 8.1.0 (clang-802.0.42)
Target: x86_64-apple-darwin16.5.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
~~~


---

Sent from sourceforge.net because openocd-***@lists.sourceforge.net is subscribed to https://sourceforge.net/p/openocd/tickets/

To unsubscribe from further messages, a project admin can change settings at https://sourceforge.net/p/openocd/admin/tickets/options. Or, if this is a mailing list, you can unsubscribe from the mailing list.
Freddie Chopin
2017-04-24 05:47:18 UTC
Permalink
I think we should change the name of `__unused` to just `unused` or maybe `UNUSED`. Traditionally all names beginning with double underscore (and underscore followed by capital letter) are reserved for compiler.

Another option is to just drop it, as it seems to me that OpenOCD disables warnings about unused arguments anyway (`-Wno-unused-parameter` is used in configure script).


---

** [tickets:#151] OpenOCD fails to build on macOS due to redefined macro**

**Status:** new
**Milestone:** 0.9.0
**Created:** Sun Apr 23, 2017 10:07 PM UTC by Girts F
**Last Updated:** Sun Apr 23, 2017 10:07 PM UTC
**Owner:** nobody


~~~
libtool: compile: gcc -DHAVE_CONFIG_H -I. -I./src -I./src -I./src/helper -DPKGDATADIR=\"/usr/local/share/openocd\" -DBINDIR=\"/usr/local/bin\" -I./jimtcl -I./jimtcl -Wall -Wstrict-prototypes -Wformat-security -Wshadow -Wextra -Wno-unused-parameter -Wbad-function-cast -Wcast-align -Wredundant-decls -Werror -g -O2 -MT src/target/openrisc/or1k_tap_xilinx_bscan.lo -MD -MP -MF src/target/openrisc/.deps/or1k_tap_xilinx_bscan.Tpo -c src/target/openrisc/or1k_tap_xilinx_bscan.c -o src/target/openrisc/or1k_tap_xilinx_bscan.o
src/target/aarch64.c:33:9: error: '__unused' macro redefined [-Werror,-Wmacro-redefined]
#define __unused __attribute((unused))
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/sys/cdefs.h:161:9: note: previous
definition is here
#define __unused __attribute__((unused))
^
1 error generated.
/bin/sh ./libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I./src -I./src -I./src/helper -DPKGDATADIR=\"/usr/local/share/openocd\" -DBINDIR=\"/usr/local/bin\" -I./jimtcl -I./jimtcl -Wall -Wstrict-prototypes -Wformat-security -Wshadow -Wextra -Wno-unused-parameter -Wbad-function-cast -Wcast-align -Wredundant-decls -Werror -g -O2 -MT src/server/src_server_libserver_la-telnet_server.lo -MD -MP -MF src/server/.deps/src_server_libserver_la-telnet_server.Tpo -c -o src/server/src_server_libserver_la-telnet_server.lo `test -f 'src/server/telnet_server.c' || echo './'`src/server/telnet_server.c
make[2]: *** [src/target/aarch64.lo] Error 1
~~~
This is on macOS 10.12.4 at commit 8addd9503eeb7704907d2340378d1200e3bbb99c.

CC version:
~~~
$ gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/c++/4.2.1
Apple LLVM version 8.1.0 (clang-802.0.42)
Target: x86_64-apple-darwin16.5.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
~~~


---

Sent from sourceforge.net because openocd-***@lists.sourceforge.net is subscribed to https://sourceforge.net/p/openocd/tickets/

To unsubscribe from further messages, a project admin can change settings at https://sourceforge.net/p/openocd/admin/tickets/options. Or, if this is a mailing list, you can unsubscribe from the mailing list.
Andreas Fritiofson
2017-04-24 09:25:20 UTC
Permalink
__unused is indeed not valid C and needs to be fixed. But I think
__attribute__ ((unused)) says the entire function may be unused, not that
the parameters can be unused. For the actual usage, it seems one of the
functions is actually used so there it can be removed. The other two
functions really seems to be unused so there we'll have to either find out
why and start using them, or remove them from compilation or even
completely.

/Andreas
I think we should change the name of __unused to just unused or maybe
UNUSED. Traditionally all names beginning with double underscore (and
underscore followed by capital letter) are reserved for compiler.
Another option is to just drop it, as it seems to me that OpenOCD disables
warnings about unused arguments anyway (-Wno-unused-parameter is used in
configure script).
------------------------------
* [tickets:#151] <https://sourceforge.net/p/openocd/tickets/151/> OpenOCD
fails to build on macOS due to redefined macro*
*Status:* new
*Milestone:* 0.9.0
*Created:* Sun Apr 23, 2017 10:07 PM UTC by Girts F
*Last Updated:* Sun Apr 23, 2017 10:07 PM UTC
*Owner:* nobody
libtool: compile: gcc -DHAVE_CONFIG_H -I. -I./src -I./src -I./src/helper -DPKGDATADIR=\"/usr/local/share/openocd\" -DBINDIR=\"/usr/local/bin\" -I./jimtcl -I./jimtcl -Wall -Wstrict-prototypes -Wformat-security -Wshadow -Wextra -Wno-unused-parameter -Wbad-function-cast -Wcast-align -Wredundant-decls -Werror -g -O2 -MT src/target/openrisc/or1k_tap_xilinx_bscan.lo -MD -MP -MF src/target/openrisc/.deps/or1k_tap_xilinx_bscan.Tpo -c src/target/openrisc/or1k_tap_xilinx_bscan.c -o src/target/openrisc/or1k_tap_xilinx_bscan.osrc/target/aarch64.c:33:9: error: '__unused' macro redefined [-Werror,-Wmacro-redefined]#define __unused __attribute((unused))
^/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/sys/cdefs.h:161:9: note: previous
definition is here#define __unused __attribute__((unused))
^1 error generated./bin/sh ./libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I./src -I./src -I./src/helper -DPKGDATADIR=\"/usr/local/share/openocd\" -DBINDIR=\"/usr/local/bin\" -I./jimtcl -I./jimtcl -Wall -Wstrict-prototypes -Wformat-security -Wshadow -Wextra -Wno-unused-parameter -Wbad-function-cast -Wcast-align -Wredundant-decls -Werror -g -O2 -MT src/server/src_server_libserver_la-telnet_server.lo -MD -MP -MF src/server/.deps/src_server_libserver_la-telnet_server.Tpo -c -o src/server/src_server_libserver_la-telnet_server.lo `test -f 'src/server/telnet_server.c' || echo './'`src/server/telnet_server.cmake[2]: *** [src/target/aarch64.lo] Error 1
This is on macOS 10.12.4 at commit 8addd9503eeb7704907d2340378d12
00e3bbb99c.
$ gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/c++/4.2.1
Apple LLVM version 8.1.0 (clang-802.0.42)
Target: x86_64-apple-darwin16.5.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
------------------------------
subscribed to https://sourceforge.net/p/openocd/tickets/
To unsubscribe from further messages, a project admin can change settings
at https://sourceforge.net/p/openocd/admin/tickets/options. Or, if this
is a mailing list, you can unsubscribe from the mailing list.
------------------------------------------------------------
------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
OpenOCD-devel mailing list
https://lists.sourceforge.net/lists/listinfo/openocd-devel
Andreas Fritiofson
2017-04-24 09:53:25 UTC
Permalink
__unused is indeed not valid C and needs to be fixed. But I think
__attribute__ ((unused)) says the entire function may be unused, not that
the parameters can be unused. For the actual usage, it seems one of the
functions is actually used so there it can be removed. The other two
functions really seems to be unused so there we'll have to either find out
why and start using them, or remove them from compilation or even
completely.

/Andreas
I think we should change the name of __unused to just unused or maybe
UNUSED. Traditionally all names beginning with double underscore (and
underscore followed by capital letter) are reserved for compiler.
Another option is to just drop it, as it seems to me that OpenOCD disables
warnings about unused arguments anyway (-Wno-unused-parameter is used in
configure script).
------------------------------
* [tickets:#151] <https://sourceforge.net/p/openocd/tickets/151/> OpenOCD
fails to build on macOS due to redefined macro*
*Status:* new
*Milestone:* 0.9.0
*Created:* Sun Apr 23, 2017 10:07 PM UTC by Girts F
*Last Updated:* Sun Apr 23, 2017 10:07 PM UTC
*Owner:* nobody
libtool: compile: gcc -DHAVE_CONFIG_H -I. -I./src -I./src -I./src/helper -DPKGDATADIR=\"/usr/local/share/openocd\" -DBINDIR=\"/usr/local/bin\" -I./jimtcl -I./jimtcl -Wall -Wstrict-prototypes -Wformat-security -Wshadow -Wextra -Wno-unused-parameter -Wbad-function-cast -Wcast-align -Wredundant-decls -Werror -g -O2 -MT src/target/openrisc/or1k_tap_xilinx_bscan.lo -MD -MP -MF src/target/openrisc/.deps/or1k_tap_xilinx_bscan.Tpo -c src/target/openrisc/or1k_tap_xilinx_bscan.c -o src/target/openrisc/or1k_tap_xilinx_bscan.osrc/target/aarch64.c:33:9: error: '__unused' macro redefined [-Werror,-Wmacro-redefined]#define __unused __attribute((unused))
^/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/sys/cdefs.h:161:9: note: previous
definition is here#define __unused __attribute__((unused))
^1 error generated./bin/sh ./libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I./src -I./src -I./src/helper -DPKGDATADIR=\"/usr/local/share/openocd\" -DBINDIR=\"/usr/local/bin\" -I./jimtcl -I./jimtcl -Wall -Wstrict-prototypes -Wformat-security -Wshadow -Wextra -Wno-unused-parameter -Wbad-function-cast -Wcast-align -Wredundant-decls -Werror -g -O2 -MT src/server/src_server_libserver_la-telnet_server.lo -MD -MP -MF src/server/.deps/src_server_libserver_la-telnet_server.Tpo -c -o src/server/src_server_libserver_la-telnet_server.lo `test -f 'src/server/telnet_server.c' || echo './'`src/server/telnet_server.cmake[2]: *** [src/target/aarch64.lo] Error 1
This is on macOS 10.12.4 at commit 8addd9503eeb7704907d2340378d12
00e3bbb99c.
$ gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/c++/4.2.1
Apple LLVM version 8.1.0 (clang-802.0.42)
Target: x86_64-apple-darwin16.5.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
------------------------------
subscribed to https://sourceforge.net/p/openocd/tickets/
To unsubscribe from further messages, a project admin can change settings
at https://sourceforge.net/p/openocd/admin/tickets/options. Or, if this
is a mailing list, you can unsubscribe from the mailing list.
------------------------------------------------------------
------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
OpenOCD-devel mailing list
https://lists.sourceforge.net/lists/listinfo/openocd-devel
---

** [tickets:#151] OpenOCD fails to build on macOS due to redefined macro**

**Status:** new
**Milestone:** 0.9.0
**Created:** Sun Apr 23, 2017 10:07 PM UTC by Girts F
**Last Updated:** Mon Apr 24, 2017 05:47 AM UTC
**Owner:** nobody


~~~
libtool: compile: gcc -DHAVE_CONFIG_H -I. -I./src -I./src -I./src/helper -DPKGDATADIR=\"/usr/local/share/openocd\" -DBINDIR=\"/usr/local/bin\" -I./jimtcl -I./jimtcl -Wall -Wstrict-prototypes -Wformat-security -Wshadow -Wextra -Wno-unused-parameter -Wbad-function-cast -Wcast-align -Wredundant-decls -Werror -g -O2 -MT src/target/openrisc/or1k_tap_xilinx_bscan.lo -MD -MP -MF src/target/openrisc/.deps/or1k_tap_xilinx_bscan.Tpo -c src/target/openrisc/or1k_tap_xilinx_bscan.c -o src/target/openrisc/or1k_tap_xilinx_bscan.o
src/target/aarch64.c:33:9: error: '__unused' macro redefined [-Werror,-Wmacro-redefined]
#define __unused __attribute((unused))
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/sys/cdefs.h:161:9: note: previous
definition is here
#define __unused __attribute__((unused))
^
1 error generated.
/bin/sh ./libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I./src -I./src -I./src/helper -DPKGDATADIR=\"/usr/local/share/openocd\" -DBINDIR=\"/usr/local/bin\" -I./jimtcl -I./jimtcl -Wall -Wstrict-prototypes -Wformat-security -Wshadow -Wextra -Wno-unused-parameter -Wbad-function-cast -Wcast-align -Wredundant-decls -Werror -g -O2 -MT src/server/src_server_libserver_la-telnet_server.lo -MD -MP -MF src/server/.deps/src_server_libserver_la-telnet_server.Tpo -c -o src/server/src_server_libserver_la-telnet_server.lo `test -f 'src/server/telnet_server.c' || echo './'`src/server/telnet_server.c
make[2]: *** [src/target/aarch64.lo] Error 1
~~~
This is on macOS 10.12.4 at commit 8addd9503eeb7704907d2340378d1200e3bbb99c.

CC version:
~~~
$ gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/c++/4.2.1
Apple LLVM version 8.1.0 (clang-802.0.42)
Target: x86_64-apple-darwin16.5.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
~~~


---

Sent from sourceforge.net because openocd-***@lists.sourceforge.net is subscribed to https://sourceforge.net/p/openocd/tickets/

To unsubscribe from further messages, a project admin can change settings at https://sourceforge.net/p/openocd/admin/tickets/options. Or, if this is a mailing list, you can unsubscribe from the mailing list.
Freddie Chopin
2017-04-24 12:14:07 UTC
Permalink
I just (mistakenly) assumed that the `__unused` macro is for function arguments, just because this is the most common situation for me (; If this is used for functions then this is entirely different matter indeed.

This is the commit which introduced the macro - http://repo.or.cz/openocd.git?a=commit;h=bf1efe05bb71b7a6fe4ec1809a6aaa9b6073aede

Can we somehow notify Mathias about this problem, so that he could give his opinion?


---

** [tickets:#151] OpenOCD fails to build on macOS due to redefined macro**

**Status:** new
**Milestone:** 0.9.0
**Created:** Sun Apr 23, 2017 10:07 PM UTC by Girts F
**Last Updated:** Mon Apr 24, 2017 05:47 AM UTC
**Owner:** nobody


~~~
libtool: compile: gcc -DHAVE_CONFIG_H -I. -I./src -I./src -I./src/helper -DPKGDATADIR=\"/usr/local/share/openocd\" -DBINDIR=\"/usr/local/bin\" -I./jimtcl -I./jimtcl -Wall -Wstrict-prototypes -Wformat-security -Wshadow -Wextra -Wno-unused-parameter -Wbad-function-cast -Wcast-align -Wredundant-decls -Werror -g -O2 -MT src/target/openrisc/or1k_tap_xilinx_bscan.lo -MD -MP -MF src/target/openrisc/.deps/or1k_tap_xilinx_bscan.Tpo -c src/target/openrisc/or1k_tap_xilinx_bscan.c -o src/target/openrisc/or1k_tap_xilinx_bscan.o
src/target/aarch64.c:33:9: error: '__unused' macro redefined [-Werror,-Wmacro-redefined]
#define __unused __attribute((unused))
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/sys/cdefs.h:161:9: note: previous
definition is here
#define __unused __attribute__((unused))
^
1 error generated.
/bin/sh ./libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I./src -I./src -I./src/helper -DPKGDATADIR=\"/usr/local/share/openocd\" -DBINDIR=\"/usr/local/bin\" -I./jimtcl -I./jimtcl -Wall -Wstrict-prototypes -Wformat-security -Wshadow -Wextra -Wno-unused-parameter -Wbad-function-cast -Wcast-align -Wredundant-decls -Werror -g -O2 -MT src/server/src_server_libserver_la-telnet_server.lo -MD -MP -MF src/server/.deps/src_server_libserver_la-telnet_server.Tpo -c -o src/server/src_server_libserver_la-telnet_server.lo `test -f 'src/server/telnet_server.c' || echo './'`src/server/telnet_server.c
make[2]: *** [src/target/aarch64.lo] Error 1
~~~
This is on macOS 10.12.4 at commit 8addd9503eeb7704907d2340378d1200e3bbb99c.

CC version:
~~~
$ gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/c++/4.2.1
Apple LLVM version 8.1.0 (clang-802.0.42)
Target: x86_64-apple-darwin16.5.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
~~~


---

Sent from sourceforge.net because openocd-***@lists.sourceforge.net is subscribed to https://sourceforge.net/p/openocd/tickets/

To unsubscribe from further messages, a project admin can change settings at https://sourceforge.net/p/openocd/admin/tickets/options. Or, if this is a mailing list, you can unsubscribe from the mailing list.
Matthias Welwarsky
2017-04-24 13:42:55 UTC
Permalink
Hi,

There are currently two occurrences of the __unused macro, one in
aarch64.c which can go away (since the function is actually used) and
one in armv8.c, which exists specifically to suppress the "unused
function" warning while allowing the compiler to evaluate the tagged
functions. I can't integrate these functions right now but I want them to
be built in order to prevent bitrot. Since the CI used to break on
warnings, I "__unused" the functions to suppress the warning.

Suggestion:
- surround the #define __unused with an "#ifndef __unused" bracket,
that should fix the problem for MacOS (the #defines are obviously
compatible).

The __unused will go away in a while, once I decide what to do with the
currently unused functions in armv8.c.

BR,
Matthias

On Monday 24 April 2017 12:14:07 Freddie Chopin wrote:


I just (mistakenly) assumed that the __unused macro is for function
arguments, just because this is the most common situation for me (; If
this is used for functions then this is entirely different matter indeed.
This is the commit which introduced the macro -
http://repo.or.cz/openocd.git?a=commit;h=bf1efe05bb71b7a6fe4ec1809
a6aaa9b6073aede[1]
Can we somehow notify Mathias about this problem, so that he could
give his opinion?
--------------------
*[tickets:#151][2] OpenOCD fails to build on macOS due to redefined
macro*
*Status:* new

*Milestone:* 0.9.0

*Created:* Sun Apr 23, 2017 10:07 PM UTC by Girts F

*Last Updated:* Mon Apr 24, 2017 05:47 AM UTC

*Owner:* nobody
libtool: compile: gcc -DHAVE_CONFIG_H -I. -I./src -I./src -I./src/helper -
DPKGDATADIR=\"/usr/local/share/openocd\" -DBINDIR=\"/usr/local/bin\"
-I./jimtcl -I./jimtcl -Wall -Wstrict-prototypes -Wformat-security -Wshadow -
Wextra -Wno-unused-parameter -Wbad-function-cast -Wcast-align -
Wredundant-decls -Werror -g -O2 -MT
src/target/openrisc/or1k_tap_xilinx_bscan.lo -MD -MP -MF
src/target/openrisc/.deps/or1k_tap_xilinx_bscan.Tpo -c
src/target/openrisc/or1k_tap_xilinx_bscan.c -o
src/target/openrisc/or1k_tap_xilinx_bscan.o
src/target/aarch64.c:33:9: error: '__unused' macro redefined [-Werror,-
Wmacro-redefined]
#define __unused __attribute((unused))
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platfor
m/Developer/SDKs/MacOSX10.12.sdk/usr/include/sys/cdefs.h:161:9:
note: previous
definition is here
#define __unused __attribute__((unused))
^
1 error generated.
/bin/sh ./libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I.
-I./src -I./src -I./src/helper -DPKGDATADIR=\"/usr/local/share/openocd\" -
DBINDIR=\"/usr/local/bin\" -I./jimtcl -I./jimtcl -Wall -Wstrict-prototypes -
Wformat-security -Wshadow -Wextra -Wno-unused-parameter -Wbad-
function-cast -Wcast-align -Wredundant-decls -Werror -g -O2 -MT
src/server/src_server_libserver_la-telnet_server.lo -MD -MP -MF
src/server/.deps/src_server_libserver_la-telnet_server.Tpo -c -o
src/server/src_server_libserver_la-telnet_server.lo `test -f
'src/server/telnet_server.c' || echo './'`src/server/telnet_server.c
make[2]: *** [src/target/aarch64.lo] Error 1
This is on macOS 10.12.4 at commit
8addd9503eeb7704907d2340378d1200e3bbb99c.
CC version:
$ gcc --version
Configured with: --
prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-
include-
dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.plat
form/Developer/SDKs/MacOSX10.12.sdk/usr/include/c++/4.2.1
Apple LLVM version 8.1.0 (clang-802.0.42)
Target: x86_64-apple-darwin16.5.0
Thread model: posix
InstalledDir:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.x
ctoolchain/usr/bin
--------------------
Sent from sourceforge.net because openocd-
***@lists.sourceforge.net is subscribed to
https://sourceforge.net/p/openocd/tickets/[3]
To unsubscribe from further messages, a project admin can change
settings at https://sourceforge.net/p/openocd/admin/tickets/options.[4]
Or, if this is a mailing list, you can unsubscribe from the mailing list.



--------
[1]
http://repo.or.cz/openocd.git?a=commit;h=bf1efe05bb71b7a6fe4ec1809
a6aaa9b6073aede
[2] https://sourceforge.net/p/openocd/tickets/151/
[3] https://sourceforge.net/p/openocd/tickets/
[4] https://sourceforge.net/p/openocd/admin/tickets/options.
Andreas Fritiofson
2017-04-24 13:53:07 UTC
Permalink
- surround the #define __unused with an "#ifndef __unused" bracket, that
should fix the problem for MacOS (the #defines are obviously compatible).
Kind of missing the point, identifiers starting with double underscore are
reserved for all uses and can't be assumed to have any specific meaning.
Change the name in that case ("attribute_unused" for example).

Another option is to simply remove "static"; if the function is exported it
will no longer be unused. With the addition of a small comment explaining
why it's exported and unused, I think that's perfectly acceptable.

/Andreas
Matthias Welwarsky
2017-04-24 15:07:44 UTC
Permalink
Post by Andreas Fritiofson
Kind of missing the point, identifiers starting with double underscore are
reserved for all uses and can't be assumed to have any specific meaning.
Change the name in that case ("attribute_unused" for example).
Makes me wonder why sys/cdefs.h on MacOS X defines __unused in
the first place. But hey, who am I to ask.
Post by Andreas Fritiofson
Another option is to simply remove "static"; if the function is exported it
will no longer be unused. With the addition of a small comment
explaining
Post by Andreas Fritiofson
why it's exported and unused, I think that's perfectly acceptable.
Hm, I'm not very much in favor of extending the visibility of a function, in a
sense it's an even dirtier trick than using a compiler attribute. I think I'll
go for "attribute_unused" or even remove the #define entirely like
Freddie Chopin suggested. As long as the function can stay where it is
and I don't need to #ifdef it entirely.

BR,
Matthias
Freddie Chopin
2017-04-24 15:29:36 UTC
Permalink
Makes me wonder why sys/cdefs.h on MacOS X defines __unused in the
first place. But hey, who am I to ask.
That's because this reservation is for this exact purpose - to allow
compiler headers to use such names freely.

Regards,
FC

Freddie Chopin
2017-04-24 13:54:47 UTC
Permalink
Post by Matthias Welwarsky
- surround the #define __unused with an "#ifndef __unused" bracket,
that should fix the problem for MacOS (the #defines are obviously
compatible).
If I understand that correctly this macro is actually needed only for
one function, right? If that's the case, why not just remove the macro
and add "__attribute__ ((unused))" directly to the function?

Regards,
FCh
Åke Rehnman
2017-04-24 14:14:47 UTC
Permalink
Same answer as 3 months ago...

In the mean while why don't you just remove that define and commit the
change since obviously it's causing trouble for other people?

/Ake
Post by Matthias Welwarsky
The __unused will go away in a while, once I decide what to do with
the currently unused functions in armv8.c.
Freddie Chopin
2017-04-24 12:20:55 UTC
Permalink
CCing Matthias, the author of the code which causes this problem.
 [tickets:#151] OpenOCD fails to build on macOS due to redefined
macro
Status: new
Milestone: 0.9.0
Created: Sun Apr 23, 2017 10:07 PM UTC by Girts F
Last Updated: Sun Apr 23, 2017 10:07 PM UTC
Owner: nobody
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I./src -I./src
-I./src/helper -DPKGDATADIR=\"/usr/local/share/openocd\"
-DBINDIR=\"/usr/local/bin\" -I./jimtcl -I./jimtcl -Wall -Wstrict-
prototypes -Wformat-security -Wshadow -Wextra -Wno-unused-parameter
-Wbad-function-cast -Wcast-align -Wredundant-decls -Werror -g -O2 -MT
src/target/openrisc/or1k_tap_xilinx_bscan.lo -MD -MP -MF
src/target/openrisc/.deps/or1k_tap_xilinx_bscan.Tpo -c
src/target/open
 risc/or1k_tap_xilinx_bscan.c -o
src/target/openrisc/or1k_tap_xilinx_bscan.o
src/target/aarch64.c:33:9: error: '__unused' macro redefined [-
Werror,-Wmacro-redefined]
#define __unused __attribute((unused))
        ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/
previous
      definition is here
#define __unused        __attribute__((unused))
        ^
1 error generated.
/bin/sh ./libtool  --tag=CC   --mode=compile gcc -DHAVE_CONFIG_H
-I.   -I./src -I./src -I./src/helper
-DPKGDATADIR=\"/usr/local/share/openocd\" -DBINDIR=\"/usr/local/bin\"
-I./jimtcl -I./jimtcl  -Wall -Wstrict-prototypes -Wformat-security
-Wshadow -Wextra -Wno-unused-parameter -Wbad-function-cast -Wcast-
align -Wredundant-decls -Werror  -g -O2 -MT
src/server/src_server_libserver_la-telnet_server.lo -MD -MP -MF
src/server/.deps/src_server_libserver_la-telnet_server.Tpo -c -o
src/server/src_server_libserver_la-telnet_server.lo `test -f
'src/server/telnet_server.c' || echo './'`src/server/telnet_server.c
make[2]: *** [src/target/aarch64.lo] Error 1
This is on macOS 10.12.4 at commit
8addd9503eeb7704907d2340378d1200e3bbb99c.
$ gcc --version
Configured with: --
prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-
include-
dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platf
orm/Developer/SDKs/MacOSX10.12.sdk/usr/include/c++/4.2.1
Apple LLVM version 8.1.0 (clang-802.0.42)
Target: x86_64-apple-darwin16.5.0
Thread model: posix
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xc
toolchain/usr/bin
is subscribed to https://sourceforge.net/p/openocd/tickets/
To unsubscribe from further messages, a project admin can change
settings at https://sourceforge.net/p/openocd/admin/tickets/options. 
 Or, if this is a mailing list, you can unsubscribe from the mailing
list.
-------------------------------------------------------------------
-----------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot__________
_____________________________________
OpenOCD-devel mailing list
https://lists.sourceforge.net/lists/listinfo/openocd-devel
Freddie Chopin
2017-04-24 12:43:34 UTC
Permalink
CCing Matthias, the author of the code which causes this problem.
 [tickets:#151] OpenOCD fails to build on macOS due to redefined
macro
Status: new
Milestone: 0.9.0
Created: Sun Apr 23, 2017 10:07 PM UTC by Girts F
Last Updated: Sun Apr 23, 2017 10:07 PM UTC
Owner: nobody
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I./src -I./src
-I./src/helper -DPKGDATADIR=\"/usr/local/share/openocd\"
-DBINDIR=\"/usr/local/bin\" -I./jimtcl -I./jimtcl -Wall -Wstrict-
prototypes -Wformat-security -Wshadow -Wextra -Wno-unused-parameter
-Wbad-function-cast -Wcast-align -Wredundant-decls -Werror -g -O2 -MT
src/target/openrisc/or1k_tap_xilinx_bscan.lo -MD -MP -MF
src/target/openrisc/.deps/or1k_tap_xilinx_bscan.Tpo -c
src/target/open
 risc/or1k_tap_xilinx_bscan.c -o
src/target/openrisc/or1k_tap_xilinx_bscan.o
src/target/aarch64.c:33:9: error: '__unused' macro redefined [-
Werror,-Wmacro-redefined]
#define __unused __attribute((unused))
        ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/
previous
      definition is here
#define __unused        __attribute__((unused))
        ^
1 error generated.
/bin/sh ./libtool  --tag=CC   --mode=compile gcc -DHAVE_CONFIG_H
-I.   -I./src -I./src -I./src/helper
-DPKGDATADIR=\"/usr/local/share/openocd\" -DBINDIR=\"/usr/local/bin\"
-I./jimtcl -I./jimtcl  -Wall -Wstrict-prototypes -Wformat-security
-Wshadow -Wextra -Wno-unused-parameter -Wbad-function-cast -Wcast-
align -Wredundant-decls -Werror  -g -O2 -MT
src/server/src_server_libserver_la-telnet_server.lo -MD -MP -MF
src/server/.deps/src_server_libserver_la-telnet_server.Tpo -c -o
src/server/src_server_libserver_la-telnet_server.lo `test -f
'src/server/telnet_server.c' || echo './'`src/server/telnet_server.c
make[2]: *** [src/target/aarch64.lo] Error 1
This is on macOS 10.12.4 at commit
8addd9503eeb7704907d2340378d1200e3bbb99c.
$ gcc --version
Configured with: --
prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-
include-
dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platf
orm/Developer/SDKs/MacOSX10.12.sdk/usr/include/c++/4.2.1
Apple LLVM version 8.1.0 (clang-802.0.42)
Target: x86_64-apple-darwin16.5.0
Thread model: posix
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xc
toolchain/usr/bin
is subscribed to https://sourceforge.net/p/openocd/tickets/
To unsubscribe from further messages, a project admin can change
settings at https://sourceforge.net/p/openocd/admin/tickets/options. 
 Or, if this is a mailing list, you can unsubscribe from the mailing
list.
-------------------------------------------------------------------
-----------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot__________
_____________________________________
OpenOCD-devel mailing list
https://lists.sourceforge.net/lists/listinfo/openocd-devel
---

** [tickets:#151] OpenOCD fails to build on macOS due to redefined macro**

**Status:** new
**Milestone:** 0.9.0
**Created:** Sun Apr 23, 2017 10:07 PM UTC by Girts F
**Last Updated:** Mon Apr 24, 2017 05:47 AM UTC
**Owner:** nobody


~~~
libtool: compile: gcc -DHAVE_CONFIG_H -I. -I./src -I./src -I./src/helper -DPKGDATADIR=\"/usr/local/share/openocd\" -DBINDIR=\"/usr/local/bin\" -I./jimtcl -I./jimtcl -Wall -Wstrict-prototypes -Wformat-security -Wshadow -Wextra -Wno-unused-parameter -Wbad-function-cast -Wcast-align -Wredundant-decls -Werror -g -O2 -MT src/target/openrisc/or1k_tap_xilinx_bscan.lo -MD -MP -MF src/target/openrisc/.deps/or1k_tap_xilinx_bscan.Tpo -c src/target/openrisc/or1k_tap_xilinx_bscan.c -o src/target/openrisc/or1k_tap_xilinx_bscan.o
src/target/aarch64.c:33:9: error: '__unused' macro redefined [-Werror,-Wmacro-redefined]
#define __unused __attribute((unused))
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/sys/cdefs.h:161:9: note: previous
definition is here
#define __unused __attribute__((unused))
^
1 error generated.
/bin/sh ./libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I./src -I./src -I./src/helper -DPKGDATADIR=\"/usr/local/share/openocd\" -DBINDIR=\"/usr/local/bin\" -I./jimtcl -I./jimtcl -Wall -Wstrict-prototypes -Wformat-security -Wshadow -Wextra -Wno-unused-parameter -Wbad-function-cast -Wcast-align -Wredundant-decls -Werror -g -O2 -MT src/server/src_server_libserver_la-telnet_server.lo -MD -MP -MF src/server/.deps/src_server_libserver_la-telnet_server.Tpo -c -o src/server/src_server_libserver_la-telnet_server.lo `test -f 'src/server/telnet_server.c' || echo './'`src/server/telnet_server.c
make[2]: *** [src/target/aarch64.lo] Error 1
~~~
This is on macOS 10.12.4 at commit 8addd9503eeb7704907d2340378d1200e3bbb99c.

CC version:
~~~
$ gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/c++/4.2.1
Apple LLVM version 8.1.0 (clang-802.0.42)
Target: x86_64-apple-darwin16.5.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
~~~


---

Sent from sourceforge.net because openocd-***@lists.sourceforge.net is subscribed to https://sourceforge.net/p/openocd/tickets/

To unsubscribe from further messages, a project admin can change settings at https://sourceforge.net/p/openocd/admin/tickets/options. Or, if this is a mailing list, you can unsubscribe from the mailing list.
Loading...