daniel-santos / mcp2210-linux

MCP2210 driver for linux
http://danielthesantos.blogspot.com/search/label/mcp2210
51 stars 31 forks source link

compilation time error #7

Open enkidu opened 10 years ago

enkidu commented 10 years ago

CC [M] /home/enkidu/mcp2210-linux/mcp2210-lib.o In file included from /usr/src/linux-headers-3.12-1-common/include/linux/linkage.h:4:0, from /usr/src/linux-headers-3.12-1-common/include/linux/kernel.h:6, from /home/enkidu/mcp2210-linux/mcp2210-lib.c:23: /home/enkidu/mcp2210-linux/mcp2210-creek.h: In function ‘pack_uint’: /usr/src/linux-headers-3.12-1-common/include/linux/compiler.h:321:20: error: call to ‘compiletime_assert_199’ declared with attribute error: BUILD_BUG_ON failed: scale_bits + value_bits >= sizeof(uint) * 8 prefix ## suffix(); \ ^ /usr/src/linux-headers-3.12-1-common/include/linux/compiler.h:326:2: note: in expansion of macro ‘compiletime_assert’ __compiletime_assert(condition, msg, prefix, suffix) ^ /usr/src/linux-headers-3.12-1-common/include/linux/compiler.h:338:2: note: in expansion of macro ‘_compiletime_assert’ _compiletime_assert(condition, msg, compiletimeassert, __LINE) ^ /usr/src/linux-headers-3.12-1-common/include/linux/bug.h:50:37: note: in expansion of macro ‘compiletime_assert’

define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)

                                 ^

/usr/src/linux-headers-3.12-1-common/include/linux/bug.h:74:2: note: in expansion of macro ‘BUILD_BUG_ON_MSG’ BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition) ^ /home/enkidu/mcp2210-linux/mcp2210-creek.h:199:2: note: in expansion of macro ‘BUILD_BUG_ON’ BUILD_BUG_ON(scale_bits + value_bits >= sizeof(uint) * 8); ^

daniel-santos commented 10 years ago

This assertion is present to assure that we aren't going to overflow a uint. I would only expect this assertion to fail if:

Also, it looks like you're building from the kernel headers and not an actual kernel source tree. I haven't actually tested that yet and if it's caused by that, it would be interesting. Please post your OS, kernel version and version of gcc.

enkidu commented 10 years ago

OS: Debian sid kernel: 3.12-1-amd64 gcc version 4.8.2 (Debian 4.8.2-12)

CFLAGS ?= -O2 -pipe -g3 <- in makefile. I have changed just nothing in sources.

daniel-santos commented 10 years ago

Oh! This function is defined inline and not __always_inline, so that's the problem. BUILD_BUG_ON will always fail if the values used in the condition are not compile-time constants. So you can comment out the BUILD_BUG_ON or change inline to __always_inline if you want to get going asap. I can probably reproduce it by setting the max inline insns to a low value and I'm guessing that's why it's occurring for you -- your compiler may have a different default max inline insns value than mine, so it just exposed this bug. In fact, it would make sense for Debian to patch their gcc like that, it likely results in slightly smaller executables.

enkidu commented 10 years ago

Ive commented it out, and module cannot find device:

[459591.340124] usb 2-7: ctl_cmd_init: pin = 127, is_mcp_endianness = 0 [459591.340132] usb 2-7: mcp2210_probe: usb_autopm_get_interface failed: -13e [459591.340142] mcp2210: probe of 2-7:1.0 failed with error -13

for now I am tied to hid, but it is suboptimal.

daniel-santos commented 10 years ago

Yes, well that error is due to issue #5.

I have pushed a fix, please give it a try and let me know as I was unable to reproduce it, although I could clearly see the error that would cause it. As to why I could not reproduce it, I'm not entirely sure (since I even tried -fno-inline). Incidentally, issue #5 is also fixed in the master branch.

enkidu commented 10 years ago

no change, neither with BUILD_BUG_ON, neither with enumeration. feel free to ask for particular debug data.

daniel-santos commented 10 years ago

(sigh) Sounds like you haven't done a proper pull. Why don't you retry that and and post the compilation error message you're getting. If it's the same one, you haven't pulled correctly because mcp2210-creek.h doesn't have a line 199 anymore, much less a BUILD_BUG_ON.

enkidu commented 10 years ago

I've removed local repo and cloned everything. git pull says I am already up-to-date. Have no idea what else can be done. In worst case I will make own driver with libusb and without hid.

2014/1/11 Daniel Santos notifications@github.com

(sigh) Sounds like you haven't done a proper pull. Why don't you retry that and and post the compilation error message you're getting. If it's the same one, you haven't pulled correctly because mcp2210-creek.h doesn't have a line 199 anymore, much less a BUILD_BUG_ON.

— Reply to this email directly or view it on GitHubhttps://github.com/daniel-santos/mcp2210-linux/issues/7#issuecomment-32109413 .

daniel-santos commented 10 years ago

Why don't you post the exact and complete output from your compilation? I too have just cloned anew and have verified that the patches are in the master branch. If you're still having a compilation problem and being lazy by just saying "it's still happening", then you aren't being helpful. I'm not customer service, I'm the maintainer of this project. I'll respond to bug reports and fix them, but I'm not going to think for you. Do a little bit of work and post the actual error message you get when compiling. In fact, it would be even more helpful to post the entire output.

EDIT: I'm not saying that you aren't having a similar problem -- it sounds like something is still wrong and without being able to reproduce it, I'm diagnostically limited.

enkidu commented 10 years ago

here is everything, from git clone to error. dont blame me, I am not maintainer, I don't know, what can I check to help you. I am not a kernel driver developer - if you need anything else, just ask. please ignore pkcs warning, it is irrelevant.

enkidu ~ $ git clone https://github.com/daniel-santos/mcp2210-linux.git Cloning into 'mcp2210-linux'... p11-kit: invalid config filename, will be ignored in the future: /etc/pkcs11/modules/gnome-keyring-module p11-kit: couldn't load module: /usr/lib/x86_64-linux-gnu/pkcs11/gnome-keyring-pkcs11.so: /usr/lib/x86_64-linux-gnu/pkcs11/gnome-keyring-pkcs11.so: cannot open shared object file: No such file or directory remote: Counting objects: 349, done. remote: Compressing objects: 100% (131/131), done. remote: Total 349 (delta 217), reused 349 (delta 217) Receiving objects: 100% (349/349), 217.18 KiB | 231.00 KiB/s, done. Resolving deltas: 100% (217/217), done. Checking connectivity... done. enkidu ~ $ cd mcp2210-linux/ enkidu ~/mcp2210-linux $ make all cp -n out-of-tree-autoconf.h.template out-of-tree-autoconf.h make -C /lib/modules/3.12-1-amd64/build M=/home/enkidu/mcp2210-linux modules make[1]: Wejście do katalogu `/usr/src/linux-headers-3.12-1-amd64' CC [M] /home/enkidu/mcp2210-linux/mcp2210-core.o CC [M] /home/enkidu/mcp2210-linux/mcp2210-ioctl.o CC [M] /home/enkidu/mcp2210-linux/mcp2210-ctl.o CC [M] /home/enkidu/mcp2210-linux/mcp2210-spi.o CC [M] /home/enkidu/mcp2210-linux/mcp2210-eeprom.o CC [M] /home/enkidu/mcp2210-linux/mcp2210-lib.o In file included from /usr/src/linux-headers-3.12-1-common/include/linux/linkage.h:4:0, from /usr/src/linux-headers-3.12-1-common/include/linux/kernel.h:6, from /home/enkidu/mcp2210-linux/mcp2210-lib.c:23: In function ‘validate_packed’, inlined from ‘pack_uint’ at /home/enkidu/mcp2210-linux/mcp2210-lib.c:313:17, inlined from ‘pack_uint_opt.part.2’ at /home/enkidu/mcp2210-linux/mcp2210-lib.c:726:8, inlined from ‘pack_uint_opt’: /usr/src/linux-headers-3.12-1-common/include/linux/compiler.h:321:20: error: call to ‘compiletime_assert_288’ declared with attribute error: BUILD_BUG_ON failed: scale_bits + value_bits >= sizeof(uint) * 8 prefix ## suffix(); \ ^ /usr/src/linux-headers-3.12-1-common/include/linux/compiler.h:326:2: note: in expansion of macro ‘compiletime_assert’ __compiletime_assert(condition, msg, prefix, suffix) ^ /usr/src/linux-headers-3.12-1-common/include/linux/compiler.h:338:2: note: in expansion of macro ‘_compiletime_assert’ _compiletime_assert(condition, msg, compiletimeassert, LINE__) ^ /usr/src/linux-headers-3.12-1-common/include/linux/bug.h:50:37: note: in expansion of macro ‘compiletime_assert’

define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)

                                 ^

/usr/src/linux-headers-3.12-1-common/include/linux/bug.h:74:2: note: in expansion of macro ‘BUILD_BUG_ON_MSG’ BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition) ^ /home/enkidu/mcp2210-linux/mcp2210-lib.c:288:2: note: in expansion of macro ‘BUILD_BUG_ON’ BUILD_BUG_ON(scale_bits + value_bits >= sizeof(uint) * 8); ^ make[4]: [/home/enkidu/mcp2210-linux/mcp2210-lib.o] Błąd 1 make[3]: [module/home/enkidu/mcp2210-linux] Błąd 2 make[2]: [sub-make] Błąd 2 make[1]: [all] Błąd 2 make[1]: Opuszczenie katalogu`/usr/src/linux-headers-3.12-1-amd64' make: *\ [modules] Błąd 2 enkidu ~/mcp2210-linux $

2014/1/12 Daniel Santos notifications@github.com

Why don't you post the exact and complete output from your compilation? I too have just cloned anew and have verified that the patches are in the master branch. If you're still having a compilation problem and being lazy by just saying "it's still happening", then you aren't being helpful. I'm not customer service, I'm the maintainer of this project. I'll respond to bug reports and fix them, but I'm not going to think for you. Do a little bit of work and post the actual error message you get when compiling. In fact, it would be even more helpful to post the entire output.

— Reply to this email directly or view it on GitHubhttps://github.com/daniel-santos/mcp2210-linux/issues/7#issuecomment-32114462 .

Dano79sk commented 10 years ago

in file mcp2210-lib.c line 719 I have changed: static inline void pack_uint_opt(struct bit_creek dest, uint value,uint value_bits, uint scale_bits, uint def) to static __always_inline void pack_uint_opt(struct bit_creek dest, uint value,uint value_bits, uint scale_bits, uint def) and afterwards it was working for me

enkidu commented 10 years ago

yes, after I changed this line to __always_inline it compiled, however I am getting

[656862.749382] usb 2-7: ctl_cmd_init: pin = 127, is_mcp_endianness = 0 [656862.749390] usb 2-7: mcp2210_probe: usb_autopm_get_interface failed: -13e [656862.749400] mcp2210: probe of 2-7:1.0 failed with error -13

when running mcp2210_bind.sh. Compilation issue seems solved. Thanks for patience.

2014/1/12 Dano79sk notifications@github.com

in file mcp2210-lib.c line 719 I have changed: static inline void pack_uint_opt(struct bit_creek dest, uint value,uint value_bits, uint scale_bits, uint def) to static __always_inline void pack_uint_opt(struct bit_creek dest, uint value,uint value_bits, uint scale_bits, uint def) and afterwards it was working for me

— Reply to this email directly or view it on GitHubhttps://github.com/daniel-santos/mcp2210-linux/issues/7#issuecomment-32120561 .

daniel-santos commented 10 years ago

ooh! Thank you very much guys!! :) I missed that one. I'm going to split that one out as well into an __always_inline stub and static (non-inlined) definition so the compile-time test never fails, but the compiler can still decide if the definition should be inlined or not.

daniel-santos commented 10 years ago

Also, I think that validate_packed should just be a macro so that we can tell which function actually triggered its failure. As it is, it just tells you that it failed, but determining what caused it to fail is left up to the user. In fact, this is probably a good candidate for a gcc feature request -- cause functions called with __attribute__((error())) to emit all inline expansions so that their source may be traced.

daniel-santos commented 10 years ago

FYI: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59783

thasti commented 10 years ago

the same applies for BUILD_BUG_ON(status != (status & 3)); in set_eeprom_byte_status(), right? that's where compiling failed for me...