Skip to contentSkip to conversation

sound/oss/dmasound: fix build when some drivers are =m and others are =y

PATCH Superseded Randy Dunlap 2 participants 3 messages Nov 18, 2021 – Nov 19, 2021 Sound

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sound/oss/dmasound: fix build when some drivers are =m and others are =y

When CONFIG_DMASOUND_ATARI=y and CONFIG_DMASOUND_Q40=m, dmasound_atari.o is built first (listed first in the Makefile), so dmasound_core.o is built as builtin, not for use by loadable modules. Then dmasound_q40.o is built and linked with the already-built dmasound_core.o, but the latter does not support use by loadable modules. This causes the missing symbol to be undefined.

Fixes this build error:
ERROR: modpost: "dmasound_deinit" [sound/oss/dmasound/dmasound_q40.ko] undefined!

Fixes 1da177e4c3f4 ("Linux-2.6.12-rc2") # "forever"
Cc Arnd Bergmann <[email protected]>
Cc Geert Uytterhoeven <[email protected]>
Cc Jaroslav Kysela <[email protected]>
Cc Takashi Iwai <[email protected]>

---
There may be some Makefile solution to this but I don't know what it is. I didn't want to spend lots of time on these old drivers.

 sound/oss/dmasound/Makefile         |    6 +++---
 sound/oss/dmasound/dmasound_atari.c |    2 +-
 sound/oss/dmasound/dmasound_core.c  |   16 ----------------
 sound/oss/dmasound/dmasound_paula.c |    2 +-
 sound/oss/dmasound/dmasound_q40.c   |    2 +-
 5 files changed, 6 insertions(+), 22 deletions(-)
sound/oss/dmasound/dmasound_atari.c +1 -1
@@ -27,7 +27,7 @@
 #include <asm/atariints.h>
 #include <asm/atari_stram.h>
 
-#include "dmasound.h"
+#include "dmasound_core.c"
 
 #define DMASOUND_ATARI_REVISION 0
 #define DMASOUND_ATARI_EDITION 3
sound/oss/dmasound/dmasound_paula.c +1 -1
@@ -30,7 +30,7 @@
 #include <asm/amigaints.h>
 #include <asm/machdep.h>
 
-#include "dmasound.h"
+#include "dmasound_core.c"
 
 #define DMASOUND_PAULA_REVISION 0
 #define DMASOUND_PAULA_EDITION 4
sound/oss/dmasound/dmasound_q40.c +1 -1
@@ -25,7 +25,7 @@
 #include <asm/q40ints.h>
 #include <asm/q40_master.h>
 
-#include "dmasound.h"
+#include "dmasound_core.c"
 
 #define DMASOUND_Q40_REVISION 0
 #define DMASOUND_Q40_EDITION 3
sound/oss/dmasound/Makefile +3 -3
@@ -3,6 +3,6 @@
 # Makefile for the DMA sound driver
 #
 
-obj-$(CONFIG_DMASOUND_ATARI)	+= dmasound_core.o dmasound_atari.o
-obj-$(CONFIG_DMASOUND_PAULA)	+= dmasound_core.o dmasound_paula.o
-obj-$(CONFIG_DMASOUND_Q40)	+= dmasound_core.o dmasound_q40.o
+obj-$(CONFIG_DMASOUND_ATARI)	+= dmasound_atari.o
+obj-$(CONFIG_DMASOUND_PAULA)	+= dmasound_paula.o
+obj-$(CONFIG_DMASOUND_Q40)	+= dmasound_q40.o
sound/oss/dmasound/dmasound_core.c +0 -16
@@ -1570,19 +1570,3 @@ char dmasound_alaw2dma8[] = {
 	3,	3,	3,	3,	3,	3,	3,	3
 };
 #endif /* HAS_8BIT_TABLES */
-
-    /*
-     *  Visible symbols for modules
-     */
-
-EXPORT_SYMBOL(dmasound);
-EXPORT_SYMBOL(dmasound_init);
-#ifdef MODULE
-EXPORT_SYMBOL(dmasound_deinit);
-#endif
-EXPORT_SYMBOL(dmasound_write_sq);
-EXPORT_SYMBOL(dmasound_catchRadius);
-#ifdef HAS_8BIT_TABLES
-EXPORT_SYMBOL(dmasound_ulaw2dma8);
-EXPORT_SYMBOL(dmasound_alaw2dma8);
-#endif
#1 lore raw
Quoted 11 lines · Randy Dunlap

When CONFIG_DMASOUND_ATARI=y and CONFIG_DMASOUND_Q40=m, dmasound_atari.o is built first (listed first in the Makefile), so dmasound_core.o is built as builtin, not for use by loadable modules. Then dmasound_q40.o is built and linked with the already-built dmasound_core.o, but the latter does not support use by loadable modules. This causes the missing symbol to be undefined.

Fixes this build error:
ERROR: modpost: "dmasound_deinit" [sound/oss/dmasound/dmasound_q40.ko] undefined!

I suspect your patch now breaks the case where multiple drivers are built-in, because that puts the same global symbols into vmlinux more than once.

sound/oss/dmasound/dmasound_core.c char dmasound_alaw2dma8[] = { · line 1582

Quoted 5 lines
sound/oss/dmasound/dmasound_core.c +0 -5
-EXPORT_SYMBOL(dmasound);
-EXPORT_SYMBOL(dmasound_init);
-#ifdef MODULE
-EXPORT_SYMBOL(dmasound_deinit);
-#endif

From a very brief look, I would think that removing this #ifdef and unconditionally defining dmasound_deinit is the correct solution here, to solve the case of the core driver being built-in but called from a loadable module, the Makefile logic is otherwise correct.

Arnd

#2 lore raw
Quoted 10 lines · Arnd Bergmann
Quoted 9 lines · Randy Dunlap

When CONFIG_DMASOUND_ATARI=y and CONFIG_DMASOUND_Q40=m, dmasound_atari.o is built first (listed first in the Makefile), so dmasound_core.o is built as builtin, not for use by loadable modules. Then dmasound_q40.o is built and linked with the already-built dmasound_core.o, but the latter does not support use by loadable modules. This causes the missing symbol to be undefined.

Quoted 6 lines
Quoted 2 lines

Fixes this build error:
ERROR: modpost: "dmasound_deinit" [sound/oss/dmasound/dmasound_q40.ko] undefined!

I suspect your patch now breaks the case where multiple drivers are built-in, because that puts the same global symbols into vmlinux more than once.

True dat.

Quoted 10 lines

sound/oss/dmasound/dmasound_core.c char dmasound_alaw2dma8[] = { · line 1582

Quoted 5 lines
sound/oss/dmasound/dmasound_core.c +0 -5
-EXPORT_SYMBOL(dmasound);
-EXPORT_SYMBOL(dmasound_init);
-#ifdef MODULE
-EXPORT_SYMBOL(dmasound_deinit);
-#endif

From a very brief look, I would think that removing this #ifdef and
unconditionally defining dmasound_deinit is the correct solution here, to solve the case of the core driver being built-in but called from a loadable module, the Makefile logic is otherwise correct.

OK, thanks for the info.
I'm not going to spend any more time on it...

Signature · 1 line
~Randy